If your espresso is bitter and sour, you're getting uneven extraction. One reason for this includes channeling: water encountering a tightly-packed puck and boring a hole through it or even lifting the puck so that water flows around it. Channeling over-extracts the areas of the puck that experience a high flow rate and under-extracts the areas that experience low flow.
Channeling is usually caused by too fine of a grind. If your machine (I'm assuming it's a pump machine) is pegging the pressure gauge at max (and dumping excess pressure internally) and your coffee tastes unevenly extracted, you may want to try grinding coarser. Not only will this reduce channeling, it'll result in less fines in the cup, also reducing bitterness.
The best thing I ever did for my espresso was to give up on the rigid rules I was first taught as a beginner. I don't time my shots, I don't use fixed brew ratios, I do everything by feel (watching the pressure build and the coffee flow) and taste. I do use a scale (for weighing beans per dose and weighing shots for repeatability). I dial in by adjusting the coffee output rather than fiddling with the grind. I only set the grind once to get a reasonable pressure (6-9 bars, no maxing out or dropping off), then fine-tune the gram output.
The biggest insight I gained from this freestyle approach is that the standard 2:1 ratio is altogether wrong for most of the light-roasted coffees you get from specialty coffee roasters. They simply will not extract properly with that small amount of water. Grinding coarser and pulling a longer shot (sometimes called a "turbo shot") gives you a much better result.