简体   繁体   中英

memcached with a java and php application

I have an application that involves logging the status of up to 8000 devices every 1-2mins via a java application, and storing the deviceid, time, and status in a table in the database.

The next component of this application, is a PHP interface which displays the most recent status of these devices (ones that are assigned to the user logging in, there may be at max 500 concurrent users ie viewing 16 devices each, but more than likely an average load of 50-100 users). The application will also print reports on the status over time of the device.

I was considering using memcached in the java application to store the most recent status for each deviceid, and then having the php application just access the memcached to populate the display. The reports on previous status would still come off the database as they are run infrequently.

My confusion has come about in deciding whether it would be performance worthy to write memcached in to this application, as the performance of memcached is apparently realised with mutliple hits per cache update. This application would likely have multiple updates (however pushed directly from the app, not the db), per cache read. But would save reads on a reasonably sized (2-3gb) status table.

Also, is there any interoperabilty issues writing/reading to memcached from different languages API's?

You probably already have an effient multi-language chaching mechanism built into your RDBMS! Its unlikely that can improve by much the caching and concurency mechanisms built into your database system. Your time would be better spent tuning your SQL to ensure it takes maximum advantage if these mechinisms. (Ensuring concurrency settings in SELECT allow "dirty reads", keeping units of work (the processing between BEGIN TRANSACTION and COMMIT) as short as possible etc. etc.).

As per comment on INNODB the following command:-

set transaction isolation level read uncommitted;

will allow you to read any inserted rows beofre they are committed and will totally igonore any locking and concurrency. This would boost you performance without causing you any problems as the Java half of the application is inserting only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM