Apache Thrift PHP is Slow
There are many reasons why some programming projects, such as PHP Thrift, are significantly slow. Possible causes include hardware and operating system issues, run-time configuration problems and compile-time configuration issues. All of these things must be addressed to keep your Apache server always up and running efficiently. Failing to address any of these problems, however, may result in continuous decline in performance of your Apache server and significant degradation of speed when loading your projects.
Instructions
-
-
1
Run the latest release and security patch of the operating system on your server; usually it is the most stable version. Many significant performance improvements have been added to the communication stacks and thread libraries of several existing operating systems, so upgrading to the latest version will help speed up your server's performance.
-
2
Apply the code below to your server, so it will disable your Domain Network Service, or DNS, lookups except for .html and .cgi files. This will enable your project to load faster because it only make requests based on the mentioned criteria:
HostnameLookups off
<Files ~ "\.(html|cgi)$">
HostnameLookups on
</Files>
-
-
3
Paste the following code to activate "FollowSymLinks" and "SymLinksIfOwnerMatch" on your project to at least control the additional checks done on the DocumentRoot path:
DocumentRoot /www/htdocs
<Directory />
Options FollowSymLinks
</Directory>
<Directory /www/htdocs>
Options -FollowSymLinks +SymLinksIfOwnerMatch
</Directory>
These extra checks are unnecessary and they can really slow down the loading of your PHP project.
-
4
Disable the "lingering_close" function in http_main.c directory of your server, but take extra care in doing so because this function is needed for the safe implementation of your PHP project:
void lingering_close (int s)
{
char junk_buffer[2048];
/* shutdown the sending side */
shutdown (s, 1);
signal (SIGALRM, lingering_death);
alarm (30);
for (;;) {
select (s for reading, 2 second timeout);
if (error) break;
if (s is ready for reading) {
if (read (s, junk_buffer, sizeof (junk_buffer)) <= 0) {
break;
}
/* just toss away whatever is here */
}
}
close (s);
}
This is more of a last resort trick and in some situations does not apply at all. It is just one of those tools that will either help or break your code.
-
1
Tips & Warnings
Learn more about PHP by joining discussion forums to seek expert advice.
Try as many tools as possible on your locally hosted website to gain more experience with PHP.
References
Resources
- Photo Credit Jupiterimages/Photos.com/Getty Images