I have many users voting on my PHP script on the Apache server and they have mysql queries running
"SELECT * FROM` table`` where` id` & gt; 'example number' where the example number may vary from user to user, but its known The lower obligation is updated every 10 minutes.
The server repeatedly voted every user
Can it be used? Is it not important that the user is given the maximum information, if
this site has 200 concurrent users peak It can be seen in time, it is highly incompetent and the cost of a lot of resources.
- Is the query pulling personal information. / Li>
- The voting request has received the 'example number' coming along with the request.
You have structured is not your question, it seems that the user is able to vote for any personal information. So I think the 'example number' is also coming in the form of a voting request.
I agree with the @roberttstephens and @phillipops taxpayers that you can use the ideal solution
- Redis
- NoSQL < Li> tune mysqeb
- memkey
But as you are already applying in the wild, the above solution will cost a cost, so it is practical The solution will suggest i.
- Add indexed to your table wrt for related columns [first thing to check]
- Enable mysql query caching
-
Use a reverse proxy - Example: Varnish [Perception 'example number' comes as part of the request] - Before this it is your application server Behind the request, be it intersection, so that MySQL does not have a query, Memack / Radis Lookup.
- Make sure you set the specific cache header set on the feedback so that the varnish can be cached.
- Then, in 200 concurrent requests, if 100 of them are inquiring for a similar number of varnish hits [this is the only benefit that Mamkatch can offer.].
- According to the implementation it does not have too much cost in case of development / testing efforts.
- I understand that this is not the answer to the exact question but I am sure it can solve your problem.
-
If the 'example number' does not come as part of the request, and you have to get it, it can be db [looking at the user's table] .] Then the @roberttstephens approach is the way to go. Just to give you the exact picture, I've refreshed the code a bit. `AddServer ('localhost', 11211);
$ inputNumber = 12345; $ CacheKey = "poll:" $ Input number; $ Result = $ m- & gt; Get ($ cacheKey); If ($ result) {return unserialize ($ result); } $ Sth = $ dbh- & gt; Prepare ("Select column 1, column 2 WHERE id = $ inputNumber"); $ Sth- & gt; Executed (); $ Poll_results = $ sth- & gt; Get (PDO :: FETCH_OBJ); $ M- & gt; Set ($ cacheKey, sort ($ poll_results)); `
No comments:
Post a Comment