开发者

APC vs Custom Mmap extension

开发者 https://www.devze.com 2023-02-13 21:01 出处:网络
Ok so i\'m working on this project that requires me to do a in memory key value store lookup on a table. The business rules that i\'m working with also dictate that that table must be read from memory

Ok so i'm working on this project that requires me to do a in memory key value store lookup on a table. The business rules that i'm working with also dictate that that table must be read from memory on each individual node and the table needs to persist across multiple requests.

So the obvious solution is use APC wi开发者_运维问答th apc_fetch(); and apc_store();

The problem is the table will consists of thousands and thousands of key value pairs and will be a couple megabytes in size (the machines this will run on are memory behemoths)

So i have some concerns in terms of performance if APC is doing serialization of the user cache on load.

If it's not then this shouldn't be that big of a deal and then it would actually be the more optimal solution.

However, if it's not would it be a better alternative to write a custom extension in C that did a binary search on a sorted file of structs persisted to disk?

Or (hopefully) would writing that custom extension just not be worth it at all.

Wins, losses, quick thoughts?

Thanks in advance


Although APC will serialize on load, the actual lookup via apc_fetch() is done via a hash-table and should exhibit no bottlenecks such as you describe. Since your machines are memory behemoths, you should consider tuning APC's tables to be large enough to hold all of your key/value pairs in memory. This can be done by setting apc.user_entries_hint in php.ini to the appropriate value for your application.


Try looking at https://serverfault.com/questions/57915/ram-disk-and-physical-raid Basically look into tmpfs on linux and use it as a regulat filesystem with whatever rules you want. Its also easy to debug&inspect outside of the app.

0

精彩评论

暂无评论...
验证码 换一张
取 消