We have a vehicle tracking system. We are using MySQL as database server. One TCP communicator fetches data from GPS device and inserts it into the database. Right now, we have 50 - 60 GPS devices communicating with the server. We have 4 GB RAM on the server. But still, the web-application which shows the data on maps, slowed down too much. How should we optimize the performance of our application?
Thanks, Saurabh
You need to profile your application to understand where the bottleneck is. Here are some generic tips.
- Roughly the total time for your page to load is a combination of 3 things: Time Spent on Server + Time spend on moving the data on the wire + Time taken by the browser to render. Measure how long each takes (use server side code to measure server time and you could use Chrome developer tools for the other 2)
- Your server side bottleneck could be the amount of time it takes to read from your mysql database. If so, you could optimize your reads or use an in-memory cache which pulls data from your db at periodic intervals.
- If moving data on the wire is taking time, you could try using cofiguring gzip compression on your webserver and reducing the size of your page
- If your page render is taking time, take a look at your javascript. If using google maps, try reducing the number of points your are trying to plot in one shot
Unless you profile your app and identify where the main bottleneck is, it is difficult to give specific answers but hope this gets you started in the right direction
There could be loads of things, to name a view:
- Table-locking queries. Are you using InnoDB or MyISAM?
- Also, check the amount of connections you have and that are allowed
- Check if there is a difference between test and live: could it be the amount of data in your database
- Check the "slow queries" log.
- In general: check if it is the database, or check if it is the code that's slow.
精彩评论