Hello there
Re: I've read plenty of times that Redis is "a drop-in replacement for Memcached" but ...
Not really. The protocol is the same, some basic commands are the same but memcache or memcached are more integrated into PHP because of historical reasons
This is not always a good thing though as you can't really control the number of connections and their being persistent or not if you use a mix of
- session handlers compiled into the memcached extension
- application level caching
Re: I've got a PHP5 app that uses memcached currently. I was going to suggest to our team we switch to Redis.
Be careful with your choice
Memcache works well
- with hundreds or thousands of incoming connections from PHP as it's multi threaded.
- does an OK job with throw away connections as it's multithreaded and it has a lower overhead in managing a lot of new connections / disposing of the old ones
- handles bigger payloads (max 1mb) better
Redis instead is single threaded and copes better with
- small to very small payloads
- persistent connections and not too many (max 100/200)
Re: I set up a redis Elasticache endpoint, but I forgot about the connect client: Can I expect my code, written for php5-memcached (set, get, delete etc) to work against Redis with no other changes other than the port number?
No don't try that, I can almost guarantee it won't work.
Why would you do that? What are you expecting to see?
Most likely your throughput from PHP will be the same or slightly slower
Memcache and Redis both perform similarly on similar hw and you can expect performance in the tens of thousands of tps (20k/30k on elasticache)
Unless you start making use of the advanced data structures that Redis allows you to store, it's simply not worth switching
re: I realize we will not be able to gain all of the benefits of lists, sets, hashes and such (until we upgrade to phpredis, predis or other), but mainly what I want to know is if the php5-memcached c library can be used to speak the limited memcached vocabulary directly to a redis server instance, or if using phpredis or other redis connector is required.
My suggestions
- Use predis
- make sure you are using php-fpm
- install hiredis on the server if you are paranoid about performance and you transfer a lot of data to and from Redis (10/15% gain on average)
I work for a big organization that just went through the very same process and it wasn't painless
Let me know how you go.
Stefano