mysql - How to implement a connection pool? -
i'm using civetweb (websocket) server. have handlers when receive data, query mysql. these spawn thread, every time there request.
until using 1 mysql connection database, setup on start off program, in combination mongoose library. threaded requests, it's causing me headaches, since mysql isn't thread-safe time mysql_select() until mysql_store_result(). have tried putting mutex around these mysql functions, perfomce drops tenfold (from ~750 requests/second ~75 requests/second).
what correct way handle this? i've heard 'connection pool', it's hard find simple examples google (or wrap head around sane implementation).
it seems unlikely i'm first person encounter such problem :).
i'm not sure if you. i'd put in comment don't have enough reputation yet.
i had same problem in vb.net when added multi threading application. correct there made sure call connection.open before of queries , added "pooling=true;" end of mysql connection string. mysql determine if needs open connection or using existing one.
Comments
Post a Comment