Bring a large heavy pot of salted water to a boil. Add the spaghetti and cook, stirring to separate the strands until the pasta is al dente – 7 to 8 minutes for dry pasta. Drain in a colander – reserving 1/4 cup of the pasta cooking water. Return the pasta to the pot.
Meanwhile, in a large skillet, heat the oil over medium heat. Add the bacon and cook until crisp. Add the garlic, shallots, pepper and salt and cook, stirring until fragrant and the garlic is soft but not brown – about 1 1/2 minutes.
Remove the pan from the heat and add the egg and reserved pasta cooking water – stirring quickly until the mixture thickens, but the egg does not scramble. Pour over spaghetti in pot and toss until evenly coated.
Divide the spaghetti among plates or large shallow bowls, sprinkle cheese to taste over the top of each serving and serve immediately. Makes 4 servings.