performance - MySQL and Hibernate Simultaneous read write -
i have web application has following parts:
commentators continuously doing match commentary through browser based tool. comments inserted db using hibernat.
lots of users accessing url read commentary. hibernate reading data table being updated commentators in step #1.
there stored procedures set run every 1 hour. few of them access same table (used in step #1 , #2) reading , writing/updating purpose.
now problem is, whenever site has 100+ concurrent users watching particular match commentary, mysql goes down. shows lots of queries stuck in processlist. many of them in "copying temp table" state. makes jboss restart frequently.
i using transactions in hibernate both reading , writing purposes. please because loose big matches because of these crashes.
you have performance problem. difficult give solutions work. can consider is:
1) revise hql (hibernate) statements. best write protocol <property name="show_sql">true</property> in config file (or tool log4jdbc if want see actual parameters) , analyse output. there see sql requests have most. in many cases better strategy reading , writing db data can reduce database traffic. , check have indexes table.
2) consider use second level cache. (normally hibernate uses first level cache, of no use in case because bound 1 session.) @ least requests reading actual commentaries can served cache , don't need go database. (pay attention: cache might interfere stored procedures. have if cache product use supports mysql stored procedures. in worst case have remove stored procedures critical tables , let application server job goes through cache.)
3) if few tables heavily used can consider cache them application. that's more work, perhaps can demands of application, might faster general second level cache.
4) if nothing helps , traffic heavy perhaps have invest in more hardware.
good luck ;-)
Comments
Post a Comment