Use the prepare cache to prepare on node add/up events
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.
Where is the prepared cache stored? Also usual cache concerns like TTL, size ?
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.
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.
Sized capped at ~100MB: https://github.com/datastax/cql-proxy/pull/28/commits/147ef7239c791a6abd6511443c58be413a3484f0