Assignment #8 - Memcached lab
Due: 10PM, Thurs 3/28.
This is a lab assignment you will be installing some software (MySQL and memcached) on the lab machines.
You will be doing some performance analysis using code that has been provide.
To earn your 15 points for the lab, send me your table of results by the above due date.
Overview.
Your manager loves your single-player Dungeon game so much, he wants you to make it into a multi-player online game.
Since it is a game, your manager is not really worried about high availability but it should be horizontally scalable.
Your manager has heard this memcached thingy has helped major web sites like YouTube, Flicr, and Craigslist scale.
So you should base your state management system around using memcached.
Memcached.
Memcached is a high-performance, distributed, memory caching system.
Clients can contact the memcached daemon via TCP/UDP.
It is a key/value store based on hashing. It doesn't do anything very sophisticated compared to a SQL database.
Multiple instance of memcached can be running on the same server or on multiple servers.
A particular key/value pair is stored in a single location in the pool of memcache daemons.
Clients determine the server location based on a hashing the key and contacting the appropriate daemon.
Each daemon then finds the value by hashing the key as well.
Part 1: Installing memcached and MySQL.
We can install the memcached server using Ubuntu's package management system.
You also need to install the PHP module so your web pages can get and set things in memcached.
You may also need to install MySQL if it is not already installed.
During the install of MySQL, you'll need to set the root password. Set it to be the same as the password for the machine.
Start your Apache server, verify that memcached now appears in the results from the PHP function phpinfo()
Investigate the various memcached startup option via memcached -h
If it isn't already started, you can start your memcached server via memcached -d
You can test out memcached via telnet: telnet localhost 11211.
For examples of how to get and set data, see this page.
Part 2: Benchmarking state management alternatives.
Being a good engineer, you decide to empirically test various state management options rather than just taking your manager's opinion on faith.
You will use ab to test incrementing 1000 unique keys using Apache file-based session state, MySQL, and memcached.
The file counter.zip has the PHP source code for the three benchmark pages.
Examine the code in counter_memcached.php to see how to use the memcached API.
You can find more details about the available memcached PHP function here.
You should probably have a look at the description for (at least) the get, set and check-and-set (CAS) methods.
For the PHP session benchmarking, be sure to send ab a fake PHPSESSID cookie using the -C switch. Otherwise your /tmp directory will fill with a session file for each request from ab
You will need to create the MySQL database and table by running counter.sql
Test with 10K requests with concurrency levels of 1, 8 and 16.
Report the requests per second as well as the time per request for each of the three methods (sessions, MySQL, memcached).
Submission.
Send me your table of results by the deadline.