Thumbnail request causing OOM in PHP
Sentry Issue: ENGINE-HF
ErrorException: Allowed memory size of 134217728 bytes exhausted (tried to allocate 116526568 bytes)
File "/lib/elgglib.php", line 947, in fatalErrorShutdownHandler
\Sentry\captureLastError();
File "[internal]", line 0
added scoped labels
- Developer
Example request:
https://www.minds.com/fs/v1/thumbnail/1026508015016828928/xlarge
Link to media page:
https://www.minds.com/media/1026508015016828928
- Developer
Offending section of code in
/api/v1/thumbnail.php
:try { $finfo = new \finfo(FILEINFO_MIME); $contentType = $finfo->buffer($contents) ?: 'image/jpeg'; } catch (\Exception $e) { error_log($e); $contentType = 'image/jpeg'; }
Issue appears related to
finfo
under PHP 7.3.Running a referenced test script show the clear performance degradation between our 7.1 and 7.3 builds when calling finfo.
- Developer
While I'm not able to reproduce the OOM condition in our sandbox, I am able to demonstrate the performance degradation.
- Developer
PHP 7.1
/var/www/Minds/engine # ITERS=100 php test.php Took: 0.094574928283691 /var/www/Minds/engine # ITERS=1000 php test.php Took: 0.91444492340088
PHP 7.3
/var/www/Minds/engine # ITERS=100 php test.php Took: 0.42086601257324 /var/www/Minds/engine # ITERS=1000 php test.php Took: 4.215017080307
- Developer
Likely this is a good place to start looking for the OOM issue.
Please register or sign in to reply