John Foley, the chief executive and a founder of Peloton, could barely contain his excitement. It was May 2020, just a couple of months into the pandemic’s shelter-in-place orders. With gyms locked down, people had started panic-buying Peloton’s $2,245 internet-connected exercise bikes for their homes. Revenue from the systems soared 66 percent from a year earlier, and more than one million people had signed up for the company’s online exercise classes. A backlog of orders piled up. It was a moment of triumph — and one that led to Peloton’s downfall, the New York Times reported. To meet that surging demand, the New York company aggressively ramped up production. When orders waned as gyms and fitness studios reopened, it suddenly had a glut of machines. In recent months, Peloton temporarily halted production of its bikes and treadmills. Its losses deepened. Those issues — compounded by a recall of its treadmills, the appearance of an activist investor and a spate of negative television portrayals — culminated yesterday when Foley announced that he would step down as chief executive and become executive chairman. Peloton said that it was restructuring itself, laying off 2,800 workers, or 20 percent of its work force. Barry McCarthy, a former chief financial officer of Spotify, was named chief executive and president.