Electricity crackled and arced between wires as Los Angeles residents watched, filming with their phones. And then the power died.

As temperatures have soared this summer, Angelenos have cranked up their air conditioners, straining power lines. On July 6, overloaded lines gave out and left 46,000 people sweltering in the dark.

Extreme temperatures lead to extreme electricity demand, so when sweltering weather settled over Texas in mid-July, the electric system that serves most of the state set three all-time records for power demand, one hour after another.

“This summer has been seen as a make-or-break test,” for the Electric Reliability Council of Texas, wrote Joshua Rhodes, who researches energy at the University of Texas, Austin.

Tougher tests are sure to come. Summer temperatures usually peak in August or September for the most densely populated areas of Texas and California. Every year, Los Angeles seems to set a new electricity demand record, said Martin Adams, Chief Operating Officer of the Los Angeles Department of Water and Power.

“Until the last few years we haven’t had many hot days downtown,” Adams said. “People are starting to put in air conditioning where they’ve never had it before.”

As the planet warms, higher temperatures and extreme weather are becoming more common, and that puts more stress on electric systems. The heat is already severe enough that farm workers in Georgia and Nebraska, as well as a postal worker in California, have died during this summer’s heatwaves. Rising temperatures trigger a dangerous chain reaction: More people run air conditioners to keep themselves cool, which strains electrical systems causing blackouts, which exposes people to hazardous heat.

How do we snap that chain? Experts have a few suggestions:

Replace old wires

When electricity demand surged in Los Angeles, pieces of the electrical system started to blow up. “Every weak link in the system shows up in a case like that,” Adams said. “A lot of times the failures are kind of explosive in nature.”

The sun was cooking the system from the outside, and the electricity surging through the wires was cooking it from the inside. When workers went to fix fried wires in one underground vault, a wall of 160 degree heat turned them back. They had to wait until the vault cooled to 120 degrees to check out the problem, Adams said.

It’s better for both utility workers and customers if utilities can replace aging parts ahead of time. The Los Angeles Department of Water and Power is spending about a billion dollars a year upgrading equipment, Adams said. And they’ve focused efforts on areas that get the hottest, like the San Fernando Valley.

As people around the country draw more electricity to cope with extreme weather, utilities will have to install thicker wires and quickly replace old transformers.

Let the market work

As demand for electricity soared in Texas, so did prices: A megawatt hour of power — which goes for $40 to $80 in normal conditions — went for more than $4,000. The maps charting prices in California and the Southwest turned from mellow green to high-alert red, indicating unusually high rates. That alert triggered power plant operators across the region to fire up generators that had been sitting idle until electricity prices went high enough.

“There are some power plants that operate basically only on the very hottest day of the year,” said Michael Wara, director of the climate and energy policy program at Stanford University. “These are basically aircraft engines on cement pads that can be turned on within five minutes. And they might need to earn their entire revenue in a few hours of a hot July afternoon.”

High prices also send a signal to solar companies to build more panels, especially in Texas, where the peak demand for electricity comes roughly at the same time as the sun is highest in the sky.

“I think there’s going to be a lot of solar built in Texas in the next few years,” Rhodes said. “By 2020, I wouldn’t be surprised if we had double the solar we have now.”

Although prices influence production of power, they don’t do much to change how people use electricity. “When there’s a shortage of electricity, the prices go up, but customers are mostly still paying the same price they would at any other time,” explained James Bushnell, an energy economist and the University of California, Davis.

Even if people were more exposed to electricity prices, it might not be enough to get them to run around the house unplugging appliances, Wara said. If we could get people to use less energy for non-essentials during peak hours, it could prevent blackouts before they happen. But how?

Manage demand

A while back, Rhodes’s electricity provider made him an interesting offer: Austin Energy wanted permission to control his thermostat for 15 minutes at a time, four to six times a year, when electricity demand was peaking. (Rhodes has one of those smart thermostats, so the company could adjust it remotely.) In return, Austin Energy, would pay him $85 a year. Rhodes took them up on the offer and has no regrets. He doesn’t even notice when they take over. But by making tiny adjustments to thousands of thermostats like his, the power company is able to ramp down its power demand.

In most places however, utilities haven’t gotten this sophisticated. In Los Angeles, the utility asks customers to raise their thermostats a few degrees, and to avoid doing laundry during peak times. The utility can also make a dent in demand by turning down its own machines. When things started heating up in mid-July, the utility turned off some of the massive pumps it uses to suck water hundreds of miles over mountains and hills. That alone accounted for drop of 60 megawatts, Adams said.

In the future, utilities will likely get better at strategically curbing consumption, said Mary Ann Piette, a senior scientist at the Lawrence Berkeley National Laboratory. Utilities might even be able to make surgical tweaks like preventing a neighborhood blackout by moderating its electric demand as its wires start to overload, she said. For instance, the Los Angeles Department of Water and Power might see the temperatures rising toward 160 degrees in that underground vault, and react by turning down the air conditioners of the customers downstream, allowing the equipment to cool before it blows up and leaves them with no air-conditioning at all.

The more the climate changes, the more people need electricity to cool them down. Unless we upgrade our electrical systems to prepare, there will be a lot more people sweating in the dark.