OJS 3.3 index load really slow because of getHostByAddr php function

Hi, I found trouble with our OJS 3.3 website, the homepage load very slow, sometimes > 8 sec and of course it’s unacceptable.

We use Apache 2.4, PHP 7.4 FPM and MariaDB, without heavy loaded app there.

And then I activated the php-fpm slowlog feature for any script that need time above 3s to executed.

Found this …

[12-Feb-2021 22:55:24]  [pool www] pid 24882
script_filename = /home/toni/univmed/univmed.org/ojs330/index.php
[0xf4a138b0] gethostbyaddr() /home/toni/univmed/univmed.org/ojs330/lib/pkp/classes/core/PKPRequest.inc.php:424
[0xf4a13850] getRemoteDomain() /home/toni/univmed/univmed.org/ojs330/classes/issue/IssueAction.inc.php:138
[0xf4a13670] subscribedDomain() /home/toni/univmed/univmed.org/ojs330/pages/issue/IssueHandler.inc.php:350
[0xf4a13450] _setupIssueTemplate() /home/toni/univmed/univmed.org/ojs330/pages/issue/IssueHandler.inc.php:104
[0xf4a13390] view() /home/toni/univmed/univmed.org/ojs330/lib/pkp/classes/core/PKPRouter.inc.php:395
[0xf4a132d0] _authorizeInitializeAndCallRequest() /home/toni/univmed/univmed.org/ojs330/lib/pkp/classes/core/PKPPageRouter.inc.php:246
[0xf4a13180] route() /home/toni/univmed/univmed.org/ojs330/lib/pkp/classes/core/Dispatcher.inc.php:144
[0xf4a130b0] dispatch() /home/toni/univmed/univmed.org/ojs330/lib/pkp/classes/core/PKPApplication.inc.php:364
[0xf4a13060] execute() /home/toni/univmed/univmed.org/ojs330/index.php:68
  • What you tried to resolve the issue

The issue in my case is at /lib/pkp/classes/core/PKPRequest::getRemoteDomain line 424. When OJS try to get host name using getHostByAddr function, in my case it doesn’t work nicely in our server.

And to prove it, when I try to change this line:

$remoteDomain = @getHostByAddr($this->getRemoteAddr());

to this

$remoteDomain = 'localhost.dev'; //@getHostByAddr($this->getRemoteAddr());

our OJS website load in less than 2 second.

Do you have any clue for me to fix it?

1 Like

Hi @yfktn,

Is your server’s DNS responding slowly? Looking over PHP: gethostbyaddr - Manual for references to “slow”, there are a couple of suggestions. Typically this should be a very quick operation.

Alec Smecher
Public Knowledge Project Team

1 Like