microsoft / garnet

Garnet is a remote cache-store from Microsoft Research that offers strong performance (throughput and latency), scalability, storage, recovery, cluster sharding, key migration, and replication features. Garnet can work with existing Redis clients.
https://microsoft.github.io/garnet/
MIT License
10.14k stars 501 forks source link

Any plans to support images, incr/decr inventory counting, subscribe to Postrgresql publication #253

Closed unibum closed 5 months ago

unibum commented 5 months ago

Hello, Firstly, thank you for all the hard work as well as open sourcing. Reading the few online posts, I just wanted to get better understanding of what capabilities are and are not and if on roadmap or never will be.. Use Cases im interested in is:

  1. Caching of images.. varnish seems to be the only option I can find (which is annoying as it doesn't support HTTPS OOB)
  2. Inventory counting.. Dragonfly has a solution for flash sales where they can increment/decrement stock levels at the cache layer. They actually have a number of interesting other ecommerce use case examples too.
  3. Syncing with DB.. Namely PostgreSQL.. E.g. subscribing to a publication to update cached data.. or as above, calling API back to DB say stock has run out.
  4. Pushing updates out to subscribers e.g. stock volumes as they drop, push out to all looking at page.

Cheers!

unibum commented 5 months ago

Just to add context to above #1. Varnish seems like the go to tool for caching images. unfortunately it doesnt support https etc without an additional paid service or free 3rd party app next to it to handle the https and rerouting... ideally Garnet could cache images itself (Garnet is so fast that it meets 99.9999% world users speeds/perf needs so extra capabilities seems more important than more performance), worse case Garnet could act like 3rd party app handing https and redirect to varnish. in my perfect world Garnet would plug into Ambry (linkedin document store). i.e. would be nice to have a single caching solution.. long term id like to sit either nginx or more preferable axum or salvo (rust) web servers in front, and for DB connection into postgres via pgbouncer.

yrajas commented 5 months ago

Thanks for your interest in Garnet!

Currently supported APIs are documented here https://microsoft.github.io/garnet/docs/commands/api-compatibility that can help determine if your scenarios could be handled out of the box. For any additional scenarios that are not directly supported, it is also possible to add custom logic as explained here https://microsoft.github.io/garnet/docs/dev/custom-commands Furthermore, the roadmap section https://microsoft.github.io/garnet/docs/welcome/roadmap talks about the next set of features that are being planned.

Please feel free to post any further specific questions on how Garnet can help in your scenario.

unibum commented 5 months ago

For inventory counting, another db - tigerbeetle (zig from memory) has other important features like reservation (and of course the releasing of that reserved stock/inventory).. so if you were to implement an inventory counting capability (incl reservation, increment, decrement etc.) it would be great if it could communicate back to postgresql and/or tigerbeetle as well as subscribe to publication for updates etc. (e.g. sale closed, stop accepting purchases as example). or worse case embed tigerbeetle until a capability exists :)

Thank you for your information/response above.

badrishc commented 5 months ago
  1. You can cache images or any binary data in Garnet. You would use the GET and SET API to do so.
  2. Increment and decrement are supported, and it seems the dragonfly example you mention would work out of the box. Please try out and let us know if you run into API gaps.
  3. Many users use Garnet and Redis in front of database like Postgres. You will be responsible for managing cache consistency and invalidation outside the system.
  4. Pub/sub is available in Garnet.
unibum commented 5 months ago
  1. You can cache images or any binary data in Garnet. You would use the GET and SET API to do so.

    1. Increment and decrement are supported, and it seems the dragonfly example you mention would work out of the box. Please try out and let us know if you run into API gaps.

    2. Many users use Garnet and Redis in front of database like Postgres. You will be responsible for managing cache consistency and invalidation outside the system.

    3. Pub/sub is available in Garnet.

Hello, thank you for detailed reply. Just to clarify 1) Any limits to caching image e.g. size? anything which might impact garnet performance to be aware of. 2) When you say user use Garnet and Redis infront.. are you saying they are used side by side in parallel/same time? if so, could you please clarify why someone would use Redis and not Garnet? Garnet seems to have far greater performance and extensive APIs.. so not clear to me why someone might use Redis. what scenario for example?

Lastly, thank you again for taking time to reply to earlier questions, it is greatly appreciated, especially the quick response the team has provided.

badrishc commented 5 months ago
  1. Any limits to caching image e.g. size? anything which might impact garnet performance to be aware of.

You can cache any value size up to around 500MB. You will need to adjust the page size when configuring Garnet, see --page option here.

  1. When you say user use Garnet and Redis infront.. are you saying they are used side by side in parallel/same time? if so, could you please clarify why someone would use Redis and not Garnet? Garnet seems to have far greater performance and extensive APIs.. so not clear to me why someone might use Redis. what scenario for example?

Oh, I just meant you can use any cache-store you prefer (Garnet, Redis, Dragonfly, or whatever) as the caching layer in front of a database. It is up to you to decide what to use - we would of course like you to try Garnet to see if it fits your scenario.