Cook the spaghetti according to the package instructions in a large pot of salted water until al dente. Reserve 1 cup of pasta water before draining the spaghetti.
In a large skillet over medium heat, cook the diced bacon or pancetta until crispy, about 5-7 minutes. Add the minced garlic to the skillet and cook for an additional 1-2 minutes.
In a separate bowl, whisk together the eggs, parmesan cheese, and black pepper until well combined.
Once the spaghetti is cooked and drained, add it to the skillet with the bacon and garlic. Toss the spaghetti until it is coated with the bacon and garlic mixture.
Remove the skillet from the heat and add the egg mixture to the spaghetti, tossing it quickly to avoid scrambling the eggs. If the mixture is too thick, add some of the reserved pasta water to loosen it up.
Serve the spaghetti carbonara hot with a sprinkle of chopped parsley on top (optional).