Warm a wide skillet over medium-low heat. Add olive oil and 2 tbsp butter.
Add sliced onions and about 1 tsp salt. Cook slowly, stirring often, until deep golden, 25–35 minutes.
Stir in garlic, thyme, and red pepper flakes. Cook 1 minute until fragrant.
Pour in balsamic vinegar and scrape up browned bits. Simmer 2 minutes until glossy, then keep warm on low.
Boil spaghetti in salted water until al dente. Reserve 1 cup cooking water, then drain.
Add pasta to the onions with a splash of pasta water and remaining 1 tbsp butter. Toss to coat.
Sprinkle in Parmesan, tossing and adding more pasta water as needed until saucy and silky.
Season with remaining salt and the black pepper. Finish with parsley and serve hot.