473,804 Members | 3,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2095

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.ne t/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.ne t/>, 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.ne t/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.ne t/>, 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******@hotmai l.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
23077
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
2993
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 speed. They had a vague idea that PHP5 has improved handling of objects over PHP4, so it would probably be faster also. In fact it seems slower. We did a few timing loops, in which a a number of objects were created and and members were...
34
2484
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, callable(*args)) return proxy which, is functionally equivalent to
28
2611
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 almost any operating system? Or is there many other reasons why? I understand there is ansi/iso C and C++ and that ANSI/ISO Code will work on any system If this is the reason why, than why don't developers create specific Python Distrubutions...
52
3869
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 (and dynamic languages in general) be someday close to compiled languages speed? What will be the future of Psyco, Pypy, Starkiller, Ironpython and all the other projects currently on development?
7
3050
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 studio 2003 .net optimization were enhanced and that i must gain in performance if I switch to VS 2003 or intel compiler. So I send him the project and he returned a compiled DLL with VS 2003. Result : the VS 2003 compiled Dll is slower than the VC6...
6
2033
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 photos at an acceptable speed. I have heard things about the virtual machine of Mr. Net, that it can run my app at a high speed....but could never compare it with Java VM and its speed. Then, what should i do? Go and learn C++ ? Do i have time for...
6
6257
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
6498
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 this works in 95% of the time, we have some fringe cases where the only thing returned is the processor name. We use this data to help us decide which PCs need to be updated, so it would be nice to have the processor speed in all cases.
4
8624
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 speed), ALWAYS. However, my download speed doesn't go over 25MB/s. And when my brother turns on the internet from his computer and takes up half the download/upload speeds (routers automatically split the speeds in two when two computers are using...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10578
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.