A hydraulic-pressure generator comprising: a secondary piston which is connected with a brake pedal and is displaced in a cylinder tube accompanied by movement of the brake pedal; a primary piston which is displaced in the cylinder tube in response to displacement of the secondary piston; a first pressure chamber which is formed in the cylinder tube so as to communicate with a first hollow (401 b) formed in the primary piston, and generates in brake fluid hydraulic pressure corresponding to displacement of the primary piston; a second pressure chamber which is formed in the cylinder tube so as to communicate with a second hollow (401 a) formed in the secondary piston, and generates in the brake fluid hydraulic pressure corresponding to the displacement of the secondary piston; a reservoir which reserves the brake fluid, and communicates with the cylinder tube through a first relief port and a second relief port; one or more first communication openings which are formed in a peripheral wall surrounding the first hollow (401 b), and are switched between a first communicating state in which the one or more first communication openings communicate with the first relief port and a first non-communicating state in which the one or more first communication openings do not communicate with the first relief port; and one or more second communication openings which are formed in a peripheral wall surrounding the second hollow, and are switched between a second communicating state in which the one or more second communication openings communicate with the second relief port and a second non-communicating state in which the one or more second communication openings do not communicate with the second relief port; characterized in that a flow rate at which the brake fluid can flow through the one or more first communication openings is different from a flow rate at which the brake fluid can flow through the one or more second communication openings. a secondary piston which is connected with a brake pedal and is displaced in a cylinder tube accompanied by movement of the brake pedal; a primary piston which is displaced in the cylinder tube in response to displacement of the secondary piston; a first pressure chamber which is formed in the cylinder tube so as to communicate with a first hollow (401 b) formed in the primary piston, and generates in brake fluid hydraulic pressure corresponding to displacement of the primary piston; a second pressure chamber which is formed in the cylinder tube so as to communicate with a second hollow (401 a) formed in the secondary piston, and generates in the brake fluid hydraulic pressure corresponding to the displacement of the secondary piston; a reservoir which reserves the brake fluid, and communicates with the cylinder tube through a first relief port and a second relief port; one or more first communication openings which are formed in a peripheral wall surrounding the first hollow (401 b), and are switched between a first communicating state in which the one or more first communication openings communicate with the first relief port and a first non-communicating state in which the one or more first communication openings do not communicate with the first relief port; and one or more second communication openings which are formed in a peripheral wall surrounding the second hollow, and are switched between a second communicating state in which the one or more second communication openings communicate with the second relief port and a second non-communicating state in which the one or more second communication openings do not communicate with the second relief port; characterized in that a flow rate at which the brake fluid can flow through the one or more first communication openings is different from a flow rate at which the brake fluid can flow through the one or more second communication openings.