Imagine you want to write your own rate limiter for Apache 2.4 based on mod_lua. The idea would be to limit the requests per time interval per IP.
For this task you need to maintain a globally accessible data structure which contains for example the count of the previous requests per IP.
mod_lua kind of supports shared memory between requests with the ivm_set and ivm_get methods but only inside one worker process:
Values ... are stored on a per process basis (so they won't do much good with a prefork mpm)
Usually you are using more than one worker process. In our case we use mod_mpm_event with a couple of processes. How would you share this little "previous requests" data structure in that case?
The only way I can currently think of is to use a database which is supported by mod_lua. However, it seems to be a quite complex solution for such an easy task.
Question: How to accomplish a shared memory between all requests in mod_lua?
PS: I know there are existing rate limiters like mod_qos. Our actual use case is a different one but the rate limiter example helps to get a common understanding.