Server cache

Asked

Viewed 132 times

3

I have a system that holds more than 2000 clients and it keeps increasing, and every time they do a search, they call mysql with more than 20,000 items (and this number also continues to increase), it would be possible for me to have a cache or to do something so that it doesn’t need to always search?

I was thinking of making a system that the most searched word creates a file on the server with the first 20,30 searches, would be right?

  • Right and wrong goes according to need, I have a server running redis to "hold" relational database queries (mariadb) for X time. Do you use Varnish or something? How do clients access this mysql data by direct connection? Have you ever thought about providing an API?

  • I believe that the ideal is to cache the result of the query, Mysql has the Query Cache, but... This will only get the data from the cache (instead of "fetch again") if the WHERE is identical and also does not have INSERT/UPDATE in the table. It is unlikely to solve, but if you have a table that is not constantly updated (that is, there is a lot of read and write) and does not have WHERE specific (for example, for each user connected to the site), the Query Cache can be an alternative and easy to implement.

  • @rzani I don’t use Varnish or anything like that, I only use mysql and php for back-end and answer in json for his mobile.

  • @Inkeliz would not be feasible to the database is always updating, even more in this application beginning.

1 answer

1


For search word indexing cache it is interesting to use Elastic Search or Solar.

They allow generating a key indexing that works as a cache, so searches are made on large amounts of textual data.

Another type of cache is data query cache.

You identify the most frequently performed querys and cache the results for a period. In querys with parameters, you can generate a hash based on these parameters and prefix the cache key combined with the hash.

Some ideal tools for this are Redis, Memcached, APC, etc...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.