Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 - very slow bootstrap on shared hosting

There's a big issue I am facing with now - symfony takes 7-10sec to bootstrap. Some research showed that this is because of tons of file inclusions symfony makes at start.

On my local machine I could fix it by increasing realpath_cache_size setting at php.ini, but on shared hosting this does not work (because open_basedir restriction is in effect and php disables realpath cache in this situation).

Now I am stuck as obviosly application is not usable with such huge bootstrap delay. Does anyone have this issue.. how can I fix it?

like image 940
Pavel Dubinin Avatar asked Nov 28 '25 06:11

Pavel Dubinin


1 Answers

There are a lot of ways do fasten symfony bootstrap.

A few hints:

  • Be sure you use the "prod" environment (and production settings: debugging and profiling disabled, cache enabled, less verbose logs),
  • Under high QPS, don't use default PHP sessions handler, it uses a file lock on the user's session file, which disallow parralelized queries (it can hurt a lot if you use Ajax a lot),
  • Using the filesystem can be quite slow for caching (especially on shared hosting): put the cache directories under a tmpfs mountpoint or override the caching backend in order to use something else than the filesystem (see http://nerdpress.org/2012/07/10/caching-data-in-symfony2).

See the following checklist covering the basics of symfony2 application deployement for production: http://www.symfony2-checklist.com/

like image 99
Martin Richard Avatar answered Nov 29 '25 22:11

Martin Richard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!