Score:0

Page Loads Error

co flag

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?

jp flag
You need to profile your application to check what exactly it is spending its time on. Start by googling 'PHP profiling', 'PHP APM'.
cn flag
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?
Santosh Baruah avatar
co flag
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.
Tim avatar
gp flag
Tim
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.
jp flag
show output of `find /var/www/sessions/ | wc -l`.
Santosh Baruah avatar
co flag
Bots don't keep sessions so any bots visiting generate a new file for every page they visit. For application monitoring is there a tool you'd recommend we use?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.