More than 1 in 3 adults in the United States has prediabetes, higher-than-normal blood sugar levels that can lead to diabetes. And more than 1 in 10 has diabetes, characterized by still higher blood sugar levels that can eventually lead to eye problems, heart disease, a stroke, nerve damage and other serious health issues.

It’s possible to avoid these complications by keeping your blood sugar in check. What you eat, when you eat, your exercise habits and even how stressed you are all can affect how high (or low) your sugar level goes.

“You don’t want to wait until you have prediabetes or diabetes to start thinking about it,” said Dr. Elizabeth Halprin, chief of adult diabetes at the Joslin Diabetes Center in Boston. “You want to think about it to prevent it.”

What is blood glucose?

Your body breaks down the carbohydrates you eat and turns them into glucose, which is then absorbed into the bloodstream. This is the body’s primary source of energy.

Your pancreas senses how much glucose, or sugar, is in the blood and produces a corresponding amount of the hormone insulin. Insulin acts like a key to let sugar into your cells, which use it for fuel.

Some sugar normally remains in the blood and binds to proteins, like hemoglobin. This isn’t a problem in and of itself, but too much can be a bad thing.

“Think about when you spill milk or something sweet on the floor and how sticky it gets,” said Dr. Susan Spratt, a professor of medicine in the division of endocrinology, metabolism and nutrition at Duke University. “That’s what’s happening inside your body. It attaches to all of your vessels and kind of gums everything up.”

When blood sugar is consistently high, some people develop insulin resistance: The body stops responding well to insulin, and cells don’t take in enough glucose from the blood. The pancreas produces more insulin, but eventually can’t keep up, resulting in high blood glucose levels and, ultimately, prediabetes or diabetes.

Over time, excess sugar in the blood can damage blood vessels, leading to the long-term complications of diabetes.

How do you know if your level is healthy?

A blood glucose test directly measures how much sugar is in your blood at a point in time. Doctors usually measure glucose and A1C with blood drawn from a vein. Doctors aim to keep A1C levels under 7% in patients with diabetes to reduce their risk of developing complications while also avoiding hypoglycemia, or low blood sugar levels that can lead to lightheadedness, tremors or an irregular heartbeat and, in severe cases, can impair brain functioning.

Wearable sensors called continuous glucose monitors, which measure blood sugar in real time, can be particularly helpful for patients at risk of hypoglycemia, doctors said.

How often should I get tested?

The American Diabetes Association recommends that physicians initiate blood sugar testing in any adult who is overweight or obese and has any additional risk factor for diabetes

If results show you are prediabetic, you should have your blood tested annually. If your results are normal, you should be tested every three years.

People who don’t have risk factors should begin testing at age 35.

How does food affect your blood sugar?

Foods that are heavy in starch or carbohydrates — such as pasta, rice, bread and potatoes — or that are sugary, like cookies and soda, increase your blood sugar.

Eating protein and fats alongside carbohydrates can slow down their absorption and keep blood sugar more steady. “The rise is not as high, and the drop is not as rapid,” Halprin said.

Skipping or delaying meals and drinking alcohol in excess or on an empty stomach can cause low blood sugar, especially in people with diabetes.

What else can cause blood sugar to spike or dip?

Exercise helps bring down blood sugar by using up glucose for energy, building muscle that easily takes up glucose and reducing body fat that makes your cells resistant to insulin.

Stress causes a hormone called cortisol to increase, which signals the liver to release more glucose into the blood, Spratt said.

Not sleeping well can indirectly affect blood glucose by making it harder to eat well, lose weight, exercise and deal with stress, Halprin said.

How do you keep your blood sugar in check?

Doctors recommend that patients with diabetes or prediabetes eat a plate that is half leafy green vegetables, one quarter lean protein like fish or lentils, and one quarter starch.

Exercise — even just walking for 10 minutes after a meal — can help lower your blood sugar. It also can help with losing weight, which doctors say is an essential part of managing diabetes, in part because it reduces insulin resistance.

What drugs lower blood sugar?

When these interventions aren’t enough, doctors may prescribe medication. Metformin is a cheap and widely used first-line drug that helps the liver produce less glucose. Sulfonylureas are another older, inexpensive class of drugs that stimulate the pancreas to release more insulin, but they can cause blood sugar to drop too much and can lead to weight gain.

Diabetes drugs like Ozempic and Jardiance are more expensive, but can help with weight loss and lowering blood sugar. Insulin, which can also be expensive and must be injected, is often effective when other medications aren’t, doctors said.

“If you have a glucose problem and you’re not able to control it, don’t say no to meds,” Spratt said.