1

I’ve been trying to optimize for performance one behemoth software based on php and mysql. I have gone through caching in Apache and indexes in MySQL but it is not enough. Since all forms within this software are built and printed dynamically from configuration in the database the software sends huge number of SQL’s and does a lot of joins which slows the whole thing when there are many concurrent users connected (on average 200-300).

Since we cannot touch the code, I have seen that mysql-proxy can be placed between application server and database server and over there query results can be cached accessing redis o memchached via lua. My idea is to cache everything. However, the problems is invalidating the cache. Once record is updated how do I invalidate all cached result sets?

One of the ideas was convert SQL query into md5 and store result as a key of a set. But also do analysis of a query and store the same md5 key and references to the table. For example:

Query:

select * from products left join users on products.user_id = user.id

Cache Instance A

 3b98ab273f45af78849db563df6598d1– {result set}

Cache Instance B

products - 3b98ab273f45af78849db563df6598d1
users - 3b98ab273f45af78849db563df6598d1

So once UPDATE or INSERT or DELETE is issued on of these tables it invalidates all result sets where the particular table was queried.

I see quite a lot of work with it and I was wondering if there are any simpler methods to achieve this.

4

0 回答 0