Thread: Server Side

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    266

    Server Side

    I have recently been doing some web related stuff and I want to get started having some dynamic content. I can't decide whether to use PHP and MySQL or just write Apache modules. The job is pretty CPU intense so the module might be better for speed but PHP and MySQL really seem to know what they're doing when it comes to servers and I've heard a lot of good things about them. Which one of the two would you recommend? Would you recommend either?
    Fried chicken for everybody!
    -Kernel Sanders

  2. #2
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    The job is pretty CPU intense
    writing PHP extension is easier. Embed your extension into your PHP script.
    Last edited by audinue; 02-25-2009 at 04:40 AM.
    Just GET it OFF out my mind!!

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    They are often used together - PHP installed as an Apache module, and MySQL for database (accessed by PHP).

    I suggest PHP (you can call a C program to do the calculations from a PHP script if speed is that important).

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Quote Originally Posted by cyberfish View Post
    They are often used together - PHP installed as an Apache module, and MySQL for database (accessed by PHP).

    I suggest PHP (you can call a C program to do the calculations from a PHP script if speed is that important).
    I never thought of calling a C program. As far as difficulty, how bad is writing an Apache module for something like say a forum?
    Fried chicken for everybody!
    -Kernel Sanders

  5. #5
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by lruc View Post
    I never thought of calling a C program. As far as difficulty, how bad is writing an Apache module for something like say a forum?
    It's pointless since 90% of the load time goes on SQL queries.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  6. #6
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    It's pointless since 90% of the load time goes on SQL queries.
    That would depend on the application.

    I never thought of calling a C program. As far as difficulty, how bad is writing an Apache module for something like say a forum?
    I have never written an Apache module, but it would be a very unusual way to go about doing it to say the least, and quite possibly very difficult.

    A forum is not CPU-intensive at all, and is well suited for PHP.

    I would just do the CPU-intensive part in C, and call it from PHP. PHP is just so much more convenient.

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Yes -- I'd definitely go with PHP, and do the heavy lifting in an external C program, communicating between the two with a pipe.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by lruc View Post
    I never thought of calling a C program. As far as difficulty, how bad is writing an Apache module for something like say a forum?
    One of the SMF developers actually started to try and do that. He gave up on it. It just isn't worth it.

    A forum shouldn't be CPU intensive. The most intensive part is pretty much search. Everything else is mainly data shuffling.

  9. #9
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    A forum shouldn't be CPU intensive. The most intensive part is pretty much search. Everything else is mainly data shuffling.
    And search is probably going to be implemented by MySQL anyways.

  10. #10
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    True. Though sometimes you still want to do some additional post processing so the queries don't become massively complex. Have to look at what the setup is also. If you have multiple web servers and one DB server you might get away with shifting some of the work to the webservers.

  11. #11
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Thantos View Post
    True. Though sometimes you still want to do some additional post processing so the queries don't become massively complex. Have to look at what the setup is also. If you have multiple web servers and one DB server you might get away with shifting some of the work to the webservers.
    Running a forum with about 10000 people online at all times is no problem for a modern server. And I don't see much forums like that, so for a forum one server should do the job. But I guess we are talking about your CPU intense project, so it only serves as a comparision.

    How CPU intense will your web application be? What type of data does it need to process?
    Last edited by maxorator; 02-26-2009 at 06:17 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  12. #12
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by maxorator View Post
    Running a forum with about 10000 people online at all times is no problem for a modern server. And I don't see much forums like that, so for a forum one server should do the job. But I guess we are talking about your CPU intense project, so it only serves as a comparision.
    Um, that's not what our users were telling us. I've seen large forums that have 2+ web servers, a master database server, and a slave database server all running on different hardware and still have problems during peak times. So it can easily scale past the ability of one server to handle. But the benefit of writing it as an apache module just isn't there.

  13. #13
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Thantos View Post
    Um, that's not what our users were telling us. I've seen large forums that have 2+ web servers, a master database server, and a slave database server all running on different hardware and still have problems during peak times. So it can easily scale past the ability of one server to handle. But the benefit of writing it as an apache module just isn't there.
    Well, I guess it depends on some other factors too. But the Apache module thing wouldn't be useful for a forum for the reason I mentioned earlier - most of the load time and CPU power goes to processing the SQL queries. Even if the CPU load on the web server would decrease, the DB server would still be the bottleneck.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Since nearly everything to do with the forum is database work - the only bit of a PHPforum that is even remotely CPU intensive is the processing when posting/editing/quoting a post. This is so that the HTML-ization of the post can be done ONCE, rather than doing it every time a post is DISPLAYED (which, for normal use, is probably a factor of 10+ more frequent).

    The reason for needing more servers is probably a case of having enough RAM to cache the queries, and to have fast enough disk(s) when there isn't enough RAM. Since a forum like this, with a few 100k posts, hundreds of users, can't realistically fit in reasonable amount of RAM, it's likely that the need for a bigger database server is based on the I/O speed rather than the CPU processing ability (although I'm not 100% sure of that).

    [1]I'm slightly more familiar with PHP forum, as I have worked with a webmaster to extend it slightly, compared to vBulletin that this forum uses, but I expect it to use a similar approach.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    RAM is pretty cheap nowadays so having 10GB-20GB RAM on a server is no problem. But nevertheless, most SQL databases don't cache almost any data due to the huge amount of data they process and the amount of data they hold. That's why database servers usually don't use normal hard drives, but either SCSI or some SSD.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Where's the EPIPE signal?
    By marc.andrysco in forum Networking/Device Communication
    Replies: 0
    Last Post: 12-23-2006, 08:04 PM
  2. Client application having problem receiving from server side?
    By dp_76 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-04-2005, 02:58 PM
  3. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM
  4. socket question
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 01:54 PM
  5. Replies: 1
    Last Post: 01-07-2002, 12:17 PM