Performance considerations
hypeJunction opened this issue · 4 comments
Thanks for a great library.
I have implemented flintstone in one of my projects to store key/value pairs for URL rewrites. The datastore is growing fast, and I am wondering if this is going to become a performance hog with potentially hundreds of reads per page load and a bunch of simultaneous user sessions. Have you done any benchmarks? Was such a use case ever considered for flinstone? Should I just require memcached/redis instead?
Great question! Reading from memory is always going to be faster than reading from disk. I haven't benchmarked it to that scale but I would say choosing something like memcached/redis is a better option if you are having hundreds of reads per page. However it is a trade off - using something like memcached comes with more maintenance from a devops point of view. It's also not a permanent memory store so you would need a fallback like a database if the data does not exist. Totally depends on your use case and how willing you are to optimise your site for speed. I hope that helps :)
I do have a database table, which contains additional information about each route. I needed a fast way to rewrite all inline URLs on the page without having to query the database to get the target path.
I have integrated memcached today and left flintstone in as a fallback for servers that are not memcached. There was a considerable improvement in speed.
Great. There is a nice package written by @adammbalogh which allows you switch out flintstone for memcached/redis without any code changes, would recommend you take a look: https://github.com/adammbalogh/key-value-store
I did see it, and it does look great. My plugin integrates with a larger framework that already has a memcached wrapper, so it was easy to write my own adapter.