PHP MySQLi Singleton for Ajax-Requests end in to many processes -


i have php application uses ajax information - in back, uses php mysqli singleton. ajax-requests send every 0.5 second , read stuff out of database , deliver json string website. when open website several times (in different tabs), error because php, or rather apache, not "fork process". server has enough ram, problem taht process-limit of 130 processes reached.

cat /proc/user_beancounters ---------------------------         | held  | maxheld | numproc |  130  |     130 | 

so, know if it's possible singleton fault (like "why singletons bad") or imagine error source? error source, many mysql-processes started , reach max. limit?

i recommend post code of singleton , ajax back-end. it's hard make statement saying singleton or ajax back-end @ fault if not able @ it.

i @ number of connections more cause though. if not local application it's not uncommon actual requests take more 0.5s. 1 request might not done before call another. on time build queue sqli backend not able process fast enough , process count start rise since new requests added queue every 0.5s each connected client.

how ajax back-end look? run query straight away? launch php instance? how many concurrent connection webserver , database configured for? these things heavily determine how application behaves. also, stated. note if use singleton not live past execution of ajax call. each time make call php application starts scratch , singleton created scratch once again.

you set application (written in php or other) run time , make use of main loop. either make listen specific socket or other means have ajax back-end pass data application. running application handle database back-end , return data ajax back-end return reply. way database handler not recreate singleton time. still run queue issues if there lot of clients making requests require database look-up every 0.5s.

good luck!


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -