Reputation: 965
I am using gearman workers in my symfony app. The workers use the symfony services like doctrine and others. I can run multiple workers simultaneously. I want to know how doctrine handles db queries when it gets more than one query at a time(each worker is doing one query at the same time). Also is it possible to have different connections to db so that my gearman workers can use each connection for certain purpose like one connection to read from db and one connection to write to db ?
thanks
Upvotes: 0
Views: 598
Reputation: 62894
Each of your workers is its own process, with its own EntityManager, which each have their own connections. So, by default, you'll have one-connection-per-worker.
As far as "more than one query at a time" this is just like what happens with web-bound processes. From the database's perspective, it's exactly the same. Multiple simultaneous connections executing queries.
The tricky bits with workers is that they tend to live a lot longer than a web-bound process (which is reinitialized for each HTTP request that comes in). You need to be particularly careful that workers that sit idle may have their connections time out, so when they eventually pick a up a job, they explode.
Upvotes: 1