Answer the question
In order to leave comments, you need to log in
How does memcache work?
Hello…
At the project development stage, I ran into a question:
Is it normal to shove about 6 MB of text (YouTube class object) into 1 key. cache 6mb of text in 1 key? There can be tens of thousands of such 6 MB keys.
And another question: memcache stores data on the HDD or in RAM?
If in the operational, then the maximum I can record is 64 meters (if the limit is 64)?
Yesterday I checked the stat in memcache on localhost…
Number of bytes this server is allowed to use for storage is set to 64 Mega Bytes
And
Total number of bytes read by this server from network is already 69.00498104098 Mega Bytes
while
Number of valid items removed from cache to free memory for new itemsequals zero…
But why didn't any rewriting happen then?
Answer the question
In order to leave comments, you need to log in
code.google.com/p/memcached/wiki/FAQ#Why_are_items_limited_to_1_megabyte_in_size?
1 memcache entry cannot be larger than 1 megabyte. In order to store 6 megabytes of data for each key, you will have to recompile the memcache in a certain way, which can lead to performance degradation and other side effects.
In general, memcached is a mechanism designed for caching web pages, which rarely need to store data more than 1 megabyte in length. Perhaps you should look for another solution for caching data, or think of another way to store YouTube objects in text form.
memcached is a simple thing: it is a dictionary (like an array in php or a dict in python) of limited size, hanging in memory by a separate process with a simple access protocol that other processes can use.
If you write to it in total more than the set size limit, then the old data (which has not been used for the longest time) will be overwritten.
Think of it like $a['vasia'] = 'petya', but it's like the data in $a is persisted between calls, not only available to the specific script + that data is not guaranteed to be persisted.
Regarding the restrictions on the size of values, you should read here .
At this stage, you want to write tens of thousands of large objects (by the way, I didn’t understand which objects are 6M of text, then something about youtube) into RAM in order to provide quick access to them. I don't know if this is the problem you want to solve. This will require recompilation of memcached and a large amount of RAM.
If I understand your task correctly, then you have chosen the wrong tool. Memkesh is not intended for such volumes of data 6mbx10000video - 60gb of RAM :) I would store the videos themselves in a nosql database, and for example, cache the top500-1000 in memcash.
>>Yesterday on localhost I checked the stat in memcache…
>>Number of bytes this server is allowed to use for storage is set to 64 Mega Bytes
>>A
>>Total number of bytes read by this server from network is already 69.00498104098 Mega Bytes
>>at the same time
>>Number of valid items removed from cache to free memory for new items is zero...
The last parameter is the number of objects whose lifetime has not yet passed, but they had to be forced out due to the filling of the available RAM limit. And objects that died “of old age” are not considered here - so it’s not surprising that more information is given than is in memory - just some info has changed.
Well, about the memcache itself - you yourself can set its volume and lifetime of objects
memcache stores the data entirely in RAM and, if my memory serves me, it doesn't care about the size of the data under the key. And about the amount of data read from the network - who knows what he read there ... You need to look at how much data is spinning in it.
I believe that Total number of bytes read by this server from network takes into account the total length of the packets. those. “SET keyname_312 vaaaalllluuuueeeeeee”, and maybe even this indicator includes the total size of all received packets with GET commands.
hence the discrepancy.
about Memcache I recommend an article for reading www.opennet.ru/base/dev/memcached_tips.txt.html
much should become clear. In general, if in doubt “it will break - it will not break if 100,000 users come to the site”, try using prototyping and testing.
You can see what is happening in memcache through the telnet interface
lzone.de/articles/memcached.htm
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question