"Caching" identical MySQL results for all users

I hope to develop a LAMP application that will focus around a small table, probably less than 100 rows, possibly 5 fields per row. This table should have data stored in a readily accessible way, possibly up to once per second for each user (although this is "ideal", in practice this will probably decrease slightly). Several updates will be made to this table, but SELECTs will far surpass UPDATES.

The available hardware is not massively powerful (it will run on VPS, possibly with 512 MB of RAM), and it should be scalable - at the time of launch there can only be 10 concurrent users, but this can lead to thousands (and, as we all we hope with these things, perhaps 10,000, but more powerful equipment will be available at this level).

As such, I was wondering if someone could point me in the right direction for the starting point - all the data received will be the same for all users, so I'm trying to find out if there is a way to share this data through all users, instead of performing 10,000 identical, choose a second. Sooooo:

1) Will mysql_query_cache cache these results and allow access to data WITHOUT having to re-select each user? 2) (I apologize for how wide this question is, I would appreciate even the most brief answers)! I studied the APC cache since we already used it for the operations operations cache - is there a way to cache the data in the APC cache and just selects MYSQL once a second to update this cache and then just accesses APC for each user? Or maybe an alternative cache?

Otherwise, I can look at a separate script that processes requests and displays data, and somehow simply passes this data to the script to all users. This is not a fully formed thought, and I'm not sure about the implementation, but maybe an AJAX combo to pull the output from ... "Somewhere" ... :)

Once again, apologizing for the breadth of this question, a couple of short pointers from someone will be very, very appreciated. Thanks again in advance

+4
source share
3 answers

If you are doing something like an AJAX chat that constantly checks the server, you can look at node.js instead, which supports an open connection between the server and the browser. That way, you can have changes superimposed on the user when they happen, and you won’t need to do this redundant check once per second. It can scale very well for thousands of users and is written in javascript on the server side, therefore not too complicated.

+2
source

The problem with using the MySQL cache is that the entire table cache is invalid for any write to this table. You are better off using a caching solution like memcached or APC if you are trying to control this behavior more precisely. And yes, APC will be able to cache this information.

Another thing to keep in mind is that you need to know when you need to also invalidate the cache, so you don't have outdated data.

0
source

You can use apc, xcache or memcache to cache database queries, or you can use vanish or squid to cache gateways ...

0
source

Source: https://habr.com/ru/post/1401568/


All Articles