0

In my production Environment I'm observing a sporadic issue where pages are taking a long time to load. In the error logs we are seeing:

PHP Fatal error:  Maximum execution time of 30 seconds exceeded

The affected line is where a session is being created for the user.

The directories are physical. There are +3.5 million files in the directory. The trash collection is set for 31 days for sessions in PHP.

Could you advise on what issues we might be running into and how to resolve them?

Possible solutions I thought of:
Increase provisioned IOPS on the drive
Clear session data every X days
Change scaling policy so if number of sessions on any server goes above X number we spin up a 
new server
Change instance type of our production servers
Move session data elsewhere 
store session data in DB
AWS API GateWay
elastic caching

Could anyone advise on what issues?

6
  • 1
    You need to profile your application to check what exactly it is spending its time on. Start by googling 'PHP profiling', 'PHP APM'.
    – AlexD
    Commented Dec 21, 2021 at 9:46
  • We need more information - what is the PHP doing when it creates the session? What database/storage types in use? What size server? How great is the load?
    – shearn89
    Commented Dec 21, 2021 at 15:31
  • The issue is sporadic so i can't trigger it. The behavior is consistent that it is always the session starting that takes above 30 seconds to execute. The lines prior to that run fine, if we list the contents of the sessions directory (ls /var/www/sessions/) it takes +45 seconds just from the command line. I think application monitoring would be good but this seems to be an issue at the system level. Commented Dec 21, 2021 at 15:34
  • What OS? What instance type? Have you consider CPU credits? You talk about directories, how is that relevant? If you have 3.5m sessions cached in a folder that is probably bad, you may want to clean them up a lot sooner.
    – Tim
    Commented Dec 21, 2021 at 18:27
  • show output of find /var/www/sessions/ | wc -l.
    – AlexD
    Commented Dec 22, 2021 at 11:12

0

You must log in to answer this question.

Browse other questions tagged .