473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to speed up php?

I've got a problem with performance...

I'm working on a fairly slow embedded platform (a 200 MHz ARM board).
We run a browser and a webserver on the same platform.

I've timed the performance, and the webserver takes between 5 and 6
seconds to generate the page. Most of this time is spent running php.
The webserver is buysbox's httpd daemon, which invokes php every time a
page is served.

I'm guessing that I could save a few seconds of this time by keeping php
resident in memory so rather than incurring the overhead of starting it
every time.

So... Is this a right guess? How long does it take to load php? Is
there some way to daemonize PHP so that it doesn't have to load up every
time?

I am looking for any and all suggestions to speed this beast up....

--Yan
Oct 19 '06 #1
6 2074

CptDondo wrote:
I've got a problem with performance...

I'm working on a fairly slow embedded platform (a 200 MHz ARM board).
We run a browser and a webserver on the same platform.

I've timed the performance, and the webserver takes between 5 and 6
seconds to generate the page. Most of this time is spent running php.
The webserver is buysbox's httpd daemon, which invokes php every time a
page is served.

I'm guessing that I could save a few seconds of this time by keeping php
resident in memory so rather than incurring the overhead of starting it
every time.

So... Is this a right guess? How long does it take to load php? Is
there some way to daemonize PHP so that it doesn't have to load up every
time?

I am looking for any and all suggestions to speed this beast up....

--Yan
My advice would be to stick a fresh copy of debian 3.1 stable on the
box, no X (no gui at all), install apache and php and then save your
php scripts onto it and load them via a network connection, if you
havent used an OS without a gui before there will be some learning
involved but its useful and there are lots of useful sites out there
with step by step, and to install apache and php you just simply type
apt-get install apache. that wil download the files and run the
configuration.

i have never heard of buysboxs webserver but i am sure its rubbish.

Flamer.

Oct 20 '06 #2
On Thu, 19 Oct 2006 16:29:46 -0700, CptDondo wrote:
So... Is this a right guess? How long does it take to load php? Is
there some way to daemonize PHP so that it doesn't have to load up every
time?

I am looking for any and all suggestions to speed this beast up....
Admittedly I don't deal with embedded platforms as a rule, but you might
like to have a look at using lighttpd <http://www.lighttpd.net/with PHP
running under FastCGI, which should take out much of the process
initialisation overhead that you're noticing now. If you have some spare
RAM available (doubtful, I know, given the nature of the platform), you
could also consider using an opcode cache like APC
<http://pecl.php.net/package/APCor eAccelerator
<http://eaccelerator.net/>, which would save the script(s) being parsed on
each request.

Having said that, it may just be that the PHP script itself is taking some
time to execute, in which case there may not be much you can do.
Another option available to you is to profile the PHP script using
xdebug 2 <http://xdebug.org/>, which can generate cachegrind files you can
then view in KCacheGrind or something similar on your development machine
-- this might help lock down any bottlenecks within the script itself.

Not sure how much more advice I can give you, not being an expert in the
field, but hopefully something here can help. :)

Adam

--
Adam Harvey

To e-mail: don't make an example out of me!

Oct 20 '06 #3
CptDondo wrote:
I've got a problem with performance...

I'm working on a fairly slow embedded platform (a 200 MHz ARM board).
We run a browser and a webserver on the same platform.

I've timed the performance, and the webserver takes between 5 and 6
seconds to generate the page. Most of this time is spent running php.
The webserver is buysbox's httpd daemon, which invokes php every time a
page is served.

I'm guessing that I could save a few seconds of this time by keeping php
resident in memory so rather than incurring the overhead of starting it
every time.

So... Is this a right guess? How long does it take to load php? Is
there some way to daemonize PHP so that it doesn't have to load up every
time?
PHP initialization is fairly expensive. A couple megs of code have to
be loaded into ram; the ini file has to be parsed; a couple thousand
built-in functions have to be initialized (a lot of memory allocation).
Depending on the performance of the storage system, it could take a
while.
I am looking for any and all suggestions to speed this beast up....
As suggested, use FastCGI to avoid having to start PHP every time.
Beyond that I don't know what more could be done. Since it's an
embedded system, there probably isn't a whole lot of memory to go
around. The low performance could simply be the result of swapping.
Five seconds to generate a page sounds excessive even on a slow CPU. It
could also simply be that your PHP code is inefficient.

Oct 20 '06 #4
Adam Harvey wrote:
On Thu, 19 Oct 2006 16:29:46 -0700, CptDondo wrote:
>So... Is this a right guess? How long does it take to load php? Is
there some way to daemonize PHP so that it doesn't have to load up every
time?

I am looking for any and all suggestions to speed this beast up....

Admittedly I don't deal with embedded platforms as a rule, but you might
like to have a look at using lighttpd <http://www.lighttpd.net/with PHP
running under FastCGI, which should take out much of the process
initialisation overhead that you're noticing now.
Woo hoo! That took the generation time from about 6 seconds to just
under a second. Some of the complicated pages still take a couple of
seconds, but that's OK. Whee!
If you have some spare
RAM available (doubtful, I know, given the nature of the platform), you
could also consider using an opcode cache like APC
<http://pecl.php.net/package/APCor eAccelerator
<http://eaccelerator.net/>, which would save the script(s) being parsed on
each request.
Currently I have 32 MB, but I can add more for the production if it is
warranted.

Thanks!

--Yan
Oct 20 '06 #5
flamer di******@hotmail.com wrote:
CptDondo wrote:
>I've got a problem with performance...

I'm working on a fairly slow embedded platform (a 200 MHz ARM board).
We run a browser and a webserver on the same platform.

I've timed the performance, and the webserver takes between 5 and 6
seconds to generate the page. Most of this time is spent running php.
The webserver is buysbox's httpd daemon, which invokes php every time a
page is served.

I'm guessing that I could save a few seconds of this time by keeping php
resident in memory so rather than incurring the overhead of starting it
every time.

So... Is this a right guess? How long does it take to load php? Is
there some way to daemonize PHP so that it doesn't have to load up every
time?

I am looking for any and all suggestions to speed this beast up....

--Yan

My advice would be to stick a fresh copy of debian 3.1 stable on the
box, no X (no gui at all), install apache and php and then save your
php scripts onto it and load them via a network connection, if you
havent used an OS without a gui before there will be some learning
involved but its useful and there are lots of useful sites out there
with step by step, and to install apache and php you just simply type
apt-get install apache. that wil download the files and run the
configuration.

i have never heard of buysboxs webserver but i am sure its rubbish.

Flamer.
Your advice is worthless. If you have never heard of busybox, then you
know nothing about embedded Linux.

Colin
Oct 21 '06 #6
Colin Fine wrote:
Your advice is worthless. If you have never heard of busybox, then you
know nothing about embedded Linux.

Colin
:-)

Yup.... I wasn't going to engage, but I submitted the original patches
to let busybox httpd run php cgi... (the developers chose not to use
them and instead worked up their own, cleaner solution. Still, I like
to think I prodded them into it. :-) ) I find it ironic that now I am
not going to use busybox because of performance issues....

--Yan
Oct 21 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Yang Li Ke | last post by:
Hi guys, Is it possible to know the internet speed of the visitors with php? Thanx -- Yang
8
by: Rob Ristroph | last post by:
I have tried out PHP 5 for the first time (with assistance from this group -- thanks!). The people I was working with have a site that uses lots of php objects. They are having problems with...
34
by: Jacek Generowicz | last post by:
I have a program in which I make very good use of a memoizer: def memoize(callable): cache = {} def proxy(*args): try: return cache except KeyError: return cache.setdefault(args,...
28
by: Maboroshi | last post by:
Hi I am fairly new to programming but not as such that I am a total beginner From what I understand C and C++ are faster languages than Python. Is this because of Pythons ability to operate on...
52
by: Neuruss | last post by:
It seems there are quite a few projects aimed to improve Python's speed and, therefore, eliminate its main limitation for mainstream acceptance. I just wonder what do you all think? Will Python...
7
by: YAZ | last post by:
Hello, I have a dll which do some number crunching. Performances (execution speed) are very important in my application. I use VC6 to compile the DLL. A friend of mine told me that in Visual...
6
by: Ham | last post by:
Yeah, Gotto work with my VB.Net graphic application for days, do any possible type of code optimization, check for unhandled errors and finally come up with sth that can't process 2D graphics and...
6
by: Jassim Rahma | last post by:
I want to detect the internet speed using C# to show the user on what speed he's connecting to internet?
11
by: kyosohma | last post by:
Hi, We use a script here at work that runs whenever someone logs into their machine that logs various bits of information to a database. One of those bits is the CPU's model and speed. While...
4
by: nestle | last post by:
I have DSL with a download speed of 32MB/s and an upload speed of 8MB/s(according to my ISP), and I am using a router. My upload speed is always between 8MB/s and 9MB/s(which is above the max upload...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.