Lua Web Debugger
Lately I've been doing a lot of dabbling in Lua in my spare time. One of the ideas swirling around in my head is to have a debugger that you could run on a production webserver. Running any debugger in production is a difficult thing since your webservers are normally behind some kind of load balancer, so you don't know what machine your request will be routed to, there is also the possibility of blocking out users of your website, opening up your website to denial of service attacks, and security vulnerabilities.
To overcome these problems, there could be a central "debug service" website that is only accessible to the staff. Once you login to that website, you generate a cookie with a unique debug session id. On this website you could then set break points in production, and the production webservers could check for this debug session cookie. If the debug session cookie is valid, then appropriate break points get set on the request. If a break point is reached, then the current request thread (which must be unique to the request) does a blocking service call to the central "debug service" with information about local variables and the state of the stack, which then pushes this information back to the debugger window, which shows the source code.
Ideally you would be able to set break points in the C code and in the Lua code, and be able to step into a Lua function which happens to be implemented in C. You should also be alerted of break points that are triggered when you are in the middle of stepping through code. These break point alerts could happen if your web browser makes multiple requests to your production webserver.
Another super useful tool would be a profiler that is activated by a debug session cookie. After sending the response back to the client, a call graph that contains information about how much time is spent in each function could be sent back to the debug service which would then display it.
Similarly, a memory profiler could be created that records a snapshot of the stack whenever garbage collection is triggered along with the ability to tune how often the garbage collection happens. This would allow you to determine hot spots in memory usage that you could then set break points on. You could then use the memory inspector feature of the debugger to see what types of objects are in memory based on the metatable for that object. Ideally you would be able to sort on size of largest object(s) and by size of all objects of a given type.
Now I just need to find the time to write this tool ;-).
