Forum Moderators: coopster

Message Too Old, No Replies

Windows vs Linux for PHP usage

         

masterpp

10:27 pm on May 21, 2003 (gmt 0)

10+ Year Member



I would like to know which server is more faster for using alot of PHP and why.

1. IIS with CGI module (is extremely slow when there many visitors & CPU goes 100%)
2. IIS with ISAPI module..(i've been reading people's review on internet about this causing them alot of crash. Don't know if it true)
3. Red Hat Linux with apache module.

btw, how does linux works with php? I never tried linux yet. does it use a threadsafety like ISAPI?

daisho

2:47 pm on May 22, 2003 (gmt 0)

10+ Year Member



PHP was made for Linux/Unix then ported to windows so Linux is PHP's native platform.

The ISAPI module for PHP/IIS I beleive is not 100% tested.

CGI is slow on both Windows/IIS and Linux/Apache avoid it if you can.

PHP is most stable with 1.3.x of Apache on Linux/Unix. No wories about thread safety as apache 1.3.x is not a threading program it is a forking program.

Apache 2.x is threading and PHP has threaded support for it but the PHP team does not yet recommened it for production use.

Your best bet for PHP is to run it on Linux/Unix with Apache 1.3. That is the most stable, reliable and fastest configuration at this point.

Though I'm not an expert on Windows it is somewhat common knowlege that on the same hardware a Linux/Apache/PHP configuration will give you more performance than Windows/IIS/[ASP,PHP].

daisho.

lorax

2:59 pm on May 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Without a doubt go with Linux/PHP combo.

masterpp

4:09 pm on May 22, 2003 (gmt 0)

10+ Year Member



thanks, i don't know what is forking program does for linux apache 1.3.x. Does it do like the IIS w/ CGI module that is execute each time the visitors request the page which take lot of CPU usage.

I'm looking for which is good that many visitors are requesting the same pages at the same time. ISAPI works fine for windows, but i don't know much about Linux Apache 1.3x and 2.x. can you tell me more about it?

dvduval

4:14 pm on May 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just got an account on a Windows server with PHP, MS-SQL, Cold Fusion, and ASP.NET with 4 domains for $7/month! So far the PHP on the windows server is faster than the Linux server I moved over from. Both query a mySQL database, but the windows is faster. Of course, this is not a high traffic site either.

masterpp

4:29 pm on May 22, 2003 (gmt 0)

10+ Year Member



dvduval, what is your php module on windows? It's good that you have faster server. Probably your linux server was old.

daisho

4:32 pm on May 22, 2003 (gmt 0)

10+ Year Member



Forking is not CGI. You have CGI on Linux just like windows. Forking is basically a heavier threading model. The disadvantage is that it is slower than threading but the advantage is that if a fork crashes it does not kill the entire program. If a thread crashes it will quick likely take out the entire program.

A fork takes longer to initiate than a thread but once created it is basically it's own program with it's own memory space. Interfork communication can get a little tricky.

Anyway that's not to important.

dvduval as for your comments of PHP on Windows being faster you don't have a fair comparison. The 2 different servers are quite certainly different and the traffic on the servers are different. It's comparing Apples to Oranges.

daisho.

BCMG_Scott

1:23 pm on May 23, 2003 (gmt 0)

10+ Year Member



Speed is a relative term and is affected by many factors other than OS and application. dvduval mentioned that he is on a windows system and it is faster than the linux box he moved from, my question - was the hardware the same on both boxes? Was the NIC the same? How about the rack and router the boxes are in/connected to?

In general, given the same hardware and same applications Linux/Unix will be faster and can handle more concurrent connections than windows. If you just want to run a web server with PHP, go the Linux/Apache 1.3/PHP route. Also, be sure to get a PHP accelerator as well. There are a number out there some free, some must be purchased, but all do improve speed and performance of serving PHP pages.

Scott Geiger

masterpp

3:55 pm on May 23, 2003 (gmt 0)

10+ Year Member



how about FastCGI?

is it reliable?

[edited by: jatar_k at 4:52 pm (utc) on May 23, 2003]
[edit reason] no urls thanks [/edit]

BCMG_Scott

4:12 pm on May 23, 2003 (gmt 0)

10+ Year Member



FastCGI is a CGI "accelerator". So this will only affect PHP if you have it compiled as CGI. If you install PHP as an Apache mod then you'll need to look at things like the Zend Optimizer or PHP Accelerator, etc.

Scott

dingman

4:33 pm on May 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A fork takes longer to initiate than a thread but once created it is basically it's own program with it's own memory space. Interfork communication can get a little tricky.

Forking creates a new process with it's own task structure, stack, heap, copy of the executable code, place in the kernel's execution schedule, and so-forth. It isn't "basically" a new program, it *is* a new program. Cooperating processes created by forking can communicate through assorted inter-process communication methods, such as shared memory regions, semaphores, etc. Exactly which mechanisms are available depends on the OS. Separate processes are fairly well protected from eachothers' actions.

Threads exist within the same process, and share everything except and execution pointer. Since they share most or all of their memory space with eachother, they aren't nearly as protected from eachothers' misbehavior as separate processes. In return, they get to communicate more easily - it's two sides of the same coin.

Typically, Unix programs have made use of a forking model. As a result, lots of effort has gone into optimizing the process creation process on Unix systems, and they are quite "cheap" compared to Windows process creation. This is deffinitely true of Linux process creation. On the other hand, threads are relatively newer to the Unix scene, and fewer programs can make use of them. Windows programs, on the other hand, tend to use threads rather than forking cooperative processes. This is one reason why Apache hasn't always done very well on NT servers - Apache doesn't use threads in versions prior to 2.

See? I did get something out of that $100k education.

daisho

7:41 pm on May 23, 2003 (gmt 0)

10+ Year Member



dingman that is *basically* what I said :) Anyway your description is much more detailed and accurate.

daisho.

aspr1n

10:09 pm on May 23, 2003 (gmt 0)

10+ Year Member



without wishing to start a kernal OS debate..... ( I probably will ;) )

Forking is basically a very inefficient mechanism and the "cost" involved in creating and destroying them is quite high (relatively). Threading on the other hand should be a far more efficient, and whilst dingman is right about the cost of a Windows process creation the parent/child analogy is better suited to this threading model.

Finally... NetWare has without a doubt the most efficient threading model of all OSes (see said I would). I haven't seen any PHP benchmarks on NetWare, but a NetWare kernal thread is fundimentally different to all other models. A NetWare thread is fundimentally seperate from it's execution context (memory, stack, pointers etc) and a NetWare thread can swap in swap out executing contexts dynamically. Therefore a thread rarely crashes it's executing context does. And it is then free to bind itself to another context, and begin executing that. Also processor context switches are extremely fast on NetWare, a key reason a single processor NetWare server could out perform a quad processor NT/Linux box on things like Perl etc.

asp sits back satisfied and waits for flames....

jatar_k

10:22 pm on May 23, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



waits for flames...

being the well mannered and friendly types that we are it won't happen. ;)

aspr1n

10:35 pm on May 23, 2003 (gmt 0)

10+ Year Member



being the well mannered and friendly types that we are it won't happen.

Jolly good I can take my helmet off then ;)

Having been involved in some web server kernal side development - this page is one of the finest I've come across in discussing the scalability issues: www.kegel.com/c10k.html

asp

[edited by: jatar_k at 10:42 pm (utc) on May 23, 2003]
[edit reason] delinked [/edit]

Brett_Tabke

4:49 am on May 24, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Let me just add that I run Apache and PHP under 98. I have had nothing but problem after problem with PHP. It has run the full gambit from random glitches, to machine hangs, to it hanging Apache. The big problem is it hangs Apache and I have manually kill the task.

I turn PHP off (comment out the load line in conf file) when it is not absolutly necc for me local now.

dingman

6:49 am on May 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dingman that is *basically* what I said :)

Um, yes. I just strengthened the assertion, and fleshed it out for anyone interested. I wanted to do more detail on threads, too, but there are so many diferent approaches to what they are, still, that I don't feel like I have a solid enough grasp to be that specific. I don't even know one of them well enough to confidently employ threads in any code I write.

Brett - it's been a long time since I tried running Apache on win32, and I'm sure it's improved since then, but I can't say what you describe suprises me. I love Apache and PHP, and I've never had a problem on the Linux and BSD machines I've had under my care, but I have significantly less confidence in the Windows ports of those programs than the *nix ones.

Does the combination of Apache and NT/2k/XP work any better than 98?

Timotheos

4:45 am on May 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let me just add that I run Apache and PHP under 98. I have had nothing but problem after problem with PHP.

Really? I have the same set up but I haven't had any of the problems you've mentioned. It is slow but that's my computer :-)

olwen

6:07 am on May 25, 2003 (gmt 0)

10+ Year Member



The only problem I have with PHP and Apache under 98 is that Apache2 won't shut down properly, and that's a know bug in Apache2

masterpp

10:19 pm on May 27, 2003 (gmt 0)

10+ Year Member



so linux apache 2x is better than Win IIS ISAPI for many visitors?
What i'm looking for is that it can take over 50 visitors request the same page at the same time.
The CGI module is really BAD. the ISAPI hasn't shoot up the CPU usage, it seems good to me. I don't know about Apache 2 linux

Brett_Tabke

10:23 pm on May 27, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



>Apache2 won't shut down properly,

I'm running 1.3 and I always have to kill the task manually to shut it down if anything php has been called.

grifter

5:17 am on May 28, 2003 (gmt 0)

10+ Year Member



When choosing a host, I have this assumption that unix/linux-based hosts are going to have more competent admins, and are going to be more security-conscious. I figure hosts who choose Windows are looking to save cost on personnel, or are courting businesses who prefer Windows solutions. Anyone else factor that in?

BCMG_Scott

12:39 pm on May 28, 2003 (gmt 0)

10+ Year Member



Ok just to give some idea of what type of capacity you are looking at here are some stats on a server that I am familiar with:

CPU P3 1GHz
256K Cache
18 GB IDE (yes I know SCSI is faster, had to go with cheaper)
512 MB RAM
1 GB Swap
RH Linux 7.2
Apache 1.3.x w/ PHP 4.3.x and OpenSSL
Also running on the same server:
MySQL 4.x
Qmail POP/SMTP services

Total requests for Tuesday, May 27, 2003 =~ 900,000 across 10 different sites. One site had over 430,000 requests alone. That works out to a bit over 10 requests per second on average. Now obviously there are times when there are more and times when there are less. The default configuartion of Apache is set to handle 150 concurrent connections. You can increase it to 255 through the configuration. If you want to go higher than that you need to edit the source. However, if you go high and don't have the resources to handle it, your server will crash (learned from experience).

With regard to Novell - I have to agree, Novell Netware is a superior OS, it's more stable than any other, is probably more secure than Windows and *nix. The problem is that Novell doesn't/didn't know how to market. They missed the boat a long time ago when they continued to press forward with IPX/SPX (which is a better packet transport than TCP/IP - but that's a whole other discussion). The rest of the world was going TCP/IP and Novell was still stuck on IPX/SPX. If they had either marketed IPX better or had been able to switch to IP faster they would have been at least where Linux is today if not further ahead. Just my $0.02

Scott

dingman

4:10 pm on May 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



18 GB IDE (yes I know SCSI is faster, had to go with cheaper)

Probably not a bid deal on a server. After all, no matter how fast you get it off the disk, the data still has to go through the ethernet card and across the internet. The hard drive is highly unlikely to be the bottleneck. I've more often heard reliability cited as a reason to use SCSI, but there is less of a difference in reliability between SCSI and IDE drives than there used to be.

daisho

4:52 am on May 31, 2003 (gmt 0)

10+ Year Member



dingman that may be very untrue. With the database on the same server it can get very easily disk bound and IDE does not handle multiple accesses very well.

daisho.