I am fairly new to Redis, so far I really like it. I started to wonder however if it is better - performance wise - to use a single query that returns a large object (storing information in JSON) or if I should use more smaller queries, that return smaller objects?
Redis is single threaded application. Each query would be executed strictly one by one.
The answer depends on your needs and size of query response. If you try to get large ammount of keys in one query (with MULTI or with LUA script) you may block your server to accept new queries. One query allow you to keep total time as small as possible.
Each query is:
For example:
-------------------------------------------------------------------> time
| | | |
client send query(Q) | | got it(G)!
redis execute(E, server blocked) send response(SR)
However, if you do a lot of small queries, the total time for information to be longer.
-------------------------------------------------------------------> time
| | | | | | | | | |
client Q | | G | ... Q | | G | ...
redis E SR idle E SR idle
The answer is (if you have high loaded system):
Also if you want to save the JSON think about the mandatory use of some kind of serialization (for example messagepack or lz) to minimize memory consumption.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With