If i create a singleton class then only one object of that class can be created,now what if two request trying to instantiate the same class,php is a shared nothing architecture so it can not create single object for both request,so will it wait for one request to be completed before serving the another or it will create a separate instance for the other request at the same time?
Share
Each request launches a separate instance of PHP, and when the script has run its course it’s torn down and everything is disposed of. This usually happens in some fractions of a second. A “singleton” just means that only one instance of it will be created for each instance/run of the script. There can be many scripts in parallel that each have their own instance of the singleton. A singleton a logical concept, not a hard limit imposed by anything.