Home > Articles

Top 10 Ways to Improve mod_perl Performance

  • Print
  • + Share This

Top 10 Ways to Improve mod_perl Performance

  1. Use the Apache::DBI module to pre-connect to databases.

  1. Use the Apache::SizeLimit or Apache::GTopLimit modules to keep your server processes from growing beyond a certain size.

  1. Use the optimized routines in the Apache::Util module. The escape_html and escape_uri functionality are much faster than the pure-perl versions provided by the HTML::Entities and URI::Escape modules

  1. Be lean with your memory usage. Don't allocate huge data structures or read entire files into memory if you can avoid it.

  1. Reduce imported symbol memory usage in your code. Wherever possible add an empty array to the end of each module you "use". For example this code:

          use POSIX;
          use POSIX ();
  1. Eliminate unused Perl modules from your server. Add Apache::Status to your server to find the list of all used modules. Look for modules that may not be needed. Modify the code that uses these modules.

  1. Find the list of modules you use most often and load them at server start. This code is then shared between the various processes, resulting in drastic memory usage reduction.

    Additionally you may want to connect to a database (if you use one) to insure that all dynamically loaded code is shared.

  1. Turn off KeepAlive support in your httpd.conf file:

          KeepAlive off

    This change keeps your mod_perl processes executing requests instead of waiting for the rare second client requests.

  1. Examine your code for inefficient algorithms. The Apache::Dprof profiling module can help you identify "hot-spots" in your code.

  1. Use a lightweight "reverse proxy" server in front of your mod_perl server. Configure the reverse proxy to handle all static content, and forward any mod_perl requests to the backend mod_perl server.

  1. don't swap.... ever.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.