I am working a new PHP project that calls upon a records class to update the database. Currently every object or script that needs to do so makes a new instance of the object. In theory this could mean as many as six or seven instances per call.
The design currently calls for the object to connect to the database in the constructor method which would mean between 0 and 7 connections?
For the demo I will be using only MySQL but as it is all tucked away behind a single interface one imagines that it could easily be ported to other data stores (and probably will).
Given the nature of the project speed of response is the key optimisation point however with so many connections do I run the risk of overloading the system when demand is high and therefore slowing everything down anyway?
Is this a situation when it would simply be better (and faster overall) to use a singleton?
Or is there some way to have my cake and eat it?