This document expands on the 
Stuff about what 
This document will discuss several cases where 
First and foremost, you are expected to have a basic knowledge of how the Lua programming language works. In most cases, we will try to be as pedagogical as possible and link to documents describing the functions used in the examples, but there are also many cases where it is necessary to either just assume that "it works" or do some digging yourself into what the hows and whys of various function calls.
Setting the right once, which means 
that every call to a Lua script will spawn a new Lua state that handles that 
script and is destroyed immediately after. This option keeps the memory 
footprint of mod_lua low, but also affects the processing speed of a request. 
If you have the memory to spare, you can set the scope to thread, 
which will make mod_lua spawn a Lua state that lasts the entirity of a thread's 
lifetime, speeding up request processing by 2-3 times. Since mod_lua will create 
a state for each script, this may be an expensive move, memory-wise, so to 
compromise between speed and memory usage, you can choose the server 
option to create a pool of Lua states to be used. Each request for a Lua script or 
a hook function will then acquire a state from the pool and release it back when it's 
done using it, allowing you to still gain a significant performance increase, while 
keeping your memory footprint low. Some examples of possible settings are:
As a general rule of thumb: If your server has none to low usage, use once 
or request, if your server has low to medium usage, use the server 
pool, and if it has high usage, use the thread setting. As your server's 
load increases, so will the number of states being actively used, and having your scope 
set to once/request/conn will stop being beneficial to your memory footprint.
Note: The min and max settings for the 
server scope denotes the minimum and maximum states to keep in a pool per 
server process, so keep this below your ThreadsPerChild limit.
By default, forever value, which will cause mod_lua 
to skip the stat process and always reuse the compiled byte-code from the first access to the 
script, thus speeding up the processing. For Lua hooks, this can prove to increase peformance, 
while for scripts handled by the lua-script handler, the increase in performance 
may be negligible, as files httpd will stat the files regardless.
For maximum performance, it is generally recommended that any initialization of libraries, constants and master tables be kept outside the handle's scope:
    These first examples show how mod_lua can be used to rewrite URIs in the same 
    way that one could do using 
bla bla
    As with simple and advanced rewriting, you can use mod_lua for dynamically 
    assigning a hostname to a specific document root, much like 
    
With the authorization hooks, you can add custom auth phases to your request processing, allowing you to either add new requirements that were not previously supported by httpd, or tweaking existing ones to accommodate your needs.
If you require even more advanced control over your authorization phases, you can add custom authz providers to help you manage your server. The example below shows you how you can split a single htpasswd file into groups with different permissions:
This is an example of how you can create a load balancing mechanism. In this example, we will be setting/getting the number of requests served by each backend using IVM variables, and preferring the backend with least requests served in total:
Coming soon!
Also coming soon