8mm screws seem too small. Thread area is compounded with diameter, so even a small increase in size yields much greater hold. Also, you need to consider shear strength (flex and bending). Shear in wood is a whole different thing than shear in a rigid material like steel. Wood doesn't support the screw in the same way, so screws need more stiffness.
I would use 10mm or 12mm screws (~7/16" or 1/2"), and they should penetrate the support posts at least 50mm (2"). You can counterbore them into the post up to half the outer beam member's thickness, so a 100mm or 120mm screw (~4-5") should do. A 12mm screw works just fine in a single 2x4 post if you center it and pilot properly. It still has half an inch of wood to the edge.
Spread them vertically so they're about 1" from the top and bottom edges of the beam. Large screws require proper preparation, so pilot them appropriately--just smaller than the size of the screw shank for the threads, and the same as the shank above the threads. (Lag screws tend to have smaller shanks in the threaded area than above the threads, so account for that.)
While beams should generally rest on their posts, this is a case where I think an exception can be made. The load isn't extreme, and it's in a dry environment. Wood that doesn't get wet is more able to handle shear loads.