cql-proxy icon indicating copy to clipboard operation
cql-proxy copied to clipboard

Use the prepare cache to prepare on node add/up events

Open mpenick opened this issue 4 years ago • 4 comments

When adding a new node or restarting node its prepared cache is empty. This causes execution of prepare queries to fail with unprepared errors. We handle this at the proxy-level by handling unprepared errors with preparing the queries on the executing connection and re-executing the original request. This results in extra latency and it can cause a "stampeding herd" of preparing on the new node. To mitigate these issues we can prepare new and newly restarted nodes with the queries that are in the proxy's prepared cache before marking the node as available.

mpenick avatar Sep 02 '21 17:09 mpenick

Where is the prepared cache stored? Also usual cache concerns like TTL, size ?

prabhatjha avatar Sep 02 '21 17:09 prabhatjha

I think I am going to answer my question. :-) It's proxy's in-memory prepared cache. However, I would still like to understand TTL, size so that we don't go OOM because of that.

prabhatjha avatar Sep 02 '21 17:09 prabhatjha

It lives in the proxy. It's currently infinite on both accounts. This sounds terrible, but in practice it's not as bad as it sounds because it tends to be really small (even with many entries). That said, I have an idea to make this more robust, but it might be overkill.

mpenick avatar Sep 02 '21 17:09 mpenick

Sized capped at ~100MB: https://github.com/datastax/cql-proxy/pull/28/commits/147ef7239c791a6abd6511443c58be413a3484f0

mpenick avatar Sep 02 '21 18:09 mpenick