Bring a large pot of salted water to a boil. Add the spaghetti and cook according to the package instructions until al dente. Drain the pasta, reserving about 1/2 cup of pasta cooking water. Set the drained pasta aside.
In a large skillet, heat the olive oil over medium heat. Add the diced pancetta (or guanciale) and saut for about 4-5 minutes until it becomes crispy and slightly browned. Add the finely chopped onion and saut for another 2-3 minutes until it softens.
Stir in the minced garlic and red pepper flakes, saut for about 1 minute until fragrant.
Pour in the crushed tomatoes and season the sauce with salt and freshly ground black pepper to taste. Allow the sauce to simmer for 10-12 minutes, stirring occasionally, until it thickens slightly.
Toss the cooked and drained spaghetti into the Amatriciana sauce, ensuring it's well coated. If the sauce is too thick, add a bit of the reserved pasta cooking water to reach your desired consistency.
Plate the Spaghetti all'Amatriciana on individual plates. Sprinkle each serving with grated Pecorino Romano cheese and garnish with fresh chopped parsley, if desired.