Answer the question
In order to leave comments, you need to log in
What are the possible load optimizations for the simplest script?
Hey!
There is an elementary script:
<?php<br/>
if ($_GET['str'] != '')<br/>
{<br/>
echo strrev($_GET['str']);<br/>
}<br/>
else<br/>
{<br/>
echo 'error';<br/>
}<br/>
?><br/>
Answer the question
In order to leave comments, you need to log in
It's more of a problem with the HTTP server. Try to implement the same on node.js or translate it to nginx+php-fpm if you are using Apache.
If you really need to implement such strange functionality on the server, then you raise nginx + a simple fastcgi script written in C / C ++. Your task (string reversal) is implemented elementarily, it will work like a rocket.
Firstly, if the script is exactly like this, then you don’t need a server script in FIG, what kind of disgrace is it to strain the server for this? :)
Secondly, put ob_start in the beginning, it can help a lot , though not in all cases, but there is, however, a striking difference.
> The script works on WAMP
This I noticed. However, in this case it would be more interesting to use linux + nginx + php-fpm / node.js /
phpDeamon
Do you use exactly this script, or is there a read / write from a file? =)
In general, indeed, a hellishly strange script, it is not clear why this functionality cannot be organized directly on the client.
In general, caching is necessary here IMHO. all sorts of memcacheds.
Well, of course, nginx + php-fpm, these people are also right.
But still. Consider implementing THIS on the client.
It's hard to believe that the script in the example is real. If it's doing a lot of IO (files, pumping something off the network), then you need an asynchronous server, perhaps with a memcached cache. In the case of PHP, in my opinion, it is not solvable, the only thing is to raise as many cheap workers as possible. But on every request, the worker is locked on IO and is actually idle all the time.
Node.js has already been suggested, but I would recommend pyramid under gUnicorn:gevent, through nginx. An asynchronous server allows you to run as many green threads as you like, working cooperatively. If someone locks on IO, then he gives the processor to a neighbor. For each request, a new green thread.
I repeat, this is all only if your scripts block on IO or in some other way. If the task is CPU intensive, as in your example, then you just need to configure the server so that it fully uses all the resources of the machine (maybe there is one worker in the pool). Also find out what kind of network you have (maybe the “server” hangs on your home ADSL).
Use built-in perl/lua in nginx.
PS: what is the question - such is the answer
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question