# Performance & Scalability

## Performance & Scalability

- Large chunks of code should be preloaded in libraries. Code in BML pages is re-evaled on every request, so it should be small. If you need a lot of code, put it in a library and load it in cgi-bin/lj-bml-(init|local).pl

- Don't write temporary files to disk... all LJ code should be able to run on a cluster of web servers with no disk-based session persistence.

- If you're calling a function with a `$dbarg` parameter and you have both a `$dbs` and `$dbh` available, call the function with your `$dbs` ... otherwise the function and all its callees can't ever use the slave databases.