Server Side

This is a discussion on Server Side within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Originally Posted by matsp Since nearly everything to do with the forum is database work - the only bit of ...

  1. #16
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by matsp View Post
    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
    From what I can recall of the big forum users we had a lot of it was also Apache just handling the request. While the actual PHP code didn't take a lot of work itself there is still quite a bit of work Apache has to do. But I'm not 100% sure as I've never taken the time to really look at it.

  2. #17
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Quote Originally Posted by maxorator View Post
    It's pointless since 90% of the load time goes on SQL queries.
    I was planning on trying a multi-lingual forum that uses machine translation to show to forum in any desired language. That to me sounds pretty CPU intense and I'm not sure if PHP would even be able to translate.
    Fried chicken for everybody!
    -Kernel Sanders

  3. #18
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    And an Apache module can?

    Even if you want to do it in C/C++, calling it from PHP is probably an easier choice.

    With caching, it won't be CPU-intensive on average. If you have few enough accesses that caching won't help, you don't need to worry about CPU load at all.

  4. #19
    Code Abuser
    Join Date
    Jan 2009
    Posts
    16
    >Running a forum with about 10000 people online at all times is no problem for a modern server.
    Really? One forum I visit, which usually has a couple thousand people online, of which only about 20 are registered members, uses 2 database servers and at least 2 web servers and it's historically had a lot of problems with speed. Searching isn't even handled by their hardware -- it's sent to Google, and the results are parsed back.

    Going back to the original question, a PHP script coupled with a MySQL database will be by far the easiest, especially for a forum. Don't bother writing an Apache module, that will just cause unnecessary complication and very few benefits.
    Last edited by sorrofix; 02-28-2009 at 07:56 PM.

  5. #20
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by sorrofix View Post
    >Running a forum with about 10000 people online at all times is no problem for a modern server.
    Really? One forum I visit, which usually has a couple thousand people online, of which only about 20 are registered members, uses 2 database servers and at least 2 web servers and it's historically had a lot of problems with speed. Searching isn't even handled by their hardware -- it's sent to Google, and the results are parsed back.
    Historically doesn't matter because I'm talking about modern servers. I'm assuming their servers don't have an Intel Xeon 7400 processor, 12GB of RAM and SCSI hard drives.

    OP, did I get it right that you want to write your own translating system?
    Last edited by maxorator; 03-01-2009 at 01:39 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  6. #21
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Quote Originally Posted by maxorator View Post
    Historically doesn't matter because I'm talking about modern servers. I'm assuming their servers don't have an Intel Xeon 7400 processor, 12GB of RAM and SCSI hard drives.

    OP, did I get it right that you want to write your own translating system?
    In a way. I wont personally be doing the translating. Ill probably use google translation. Anyways I'm pretty convinced with PHP + MySQL is the best way to go. My last question is would using CGI(pre-compiled) be faster or slower than PHP + MySQL? I wouldn't mind using CGI, as long as the speed increases.
    Fried chicken for everybody!
    -Kernel Sanders

  7. #22
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Using Google's translation API makes sense. As the translating is then handled by Google's servers, it doesn't actually matter what you use. And also PHP can be pre-compiled (into bytecode), but not manually - PHP accelerators do that automatically.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  8. #23
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Something I just found on Google: http://www.wrensoft.com/zoom/benchmarks.html
    Thats pretty interesting to me because I have been assuming CGI is really slow because thats what the Wikipedia article on it seemed to imply. With those results, I would definitely change my vote to CGI. Would these results be similar on other kinds of websites?
    Fried chicken for everybody!
    -Kernel Sanders

  9. #24
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by lruc View Post
    Something I just found on Google: http://www.wrensoft.com/zoom/benchmarks.html
    Thats pretty interesting to me because I have been assuming CGI is really slow because thats what the Wikipedia article on it seemed to imply. With those results, I would definitely change my vote to CGI. Would these results be similar on other kinds of websites?
    CGI is a gateway interface, not a language. It allows you to use a script or program written in another language to be used in the web server. The most common option is to use CGI for Perl. But the option you see on that site, is native application in C++, just loaded through CGI.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  10. #25
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The problem with CGI is that a new process is launched for every query. Launching and terminating a process is slow. CGI is therefore best for things that take a long time and are used comparatively rarely, like searching. CGI gets into scaling problems if it is used for pages that are retrieved very often, and that take very little time to compute, since the process overhead far outweighs the computation time.

    FastCGI and SCGI are attempts to rectify this situation, by providing servers that manage a pool of processes for CGI execution, which reduces the overhead significantly.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  11. #26
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    For a forum about this size, would CGI or PHP be faster? I cant see any forum I make getting any bigger than this.
    Fried chicken for everybody!
    -Kernel Sanders

  12. #27
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by lruc View Post
    For a forum about this size, would CGI or PHP be faster? I cant see any forum I make getting any bigger than this.
    I very much doubt you can tell the difference - there will be three things that may limit the speed of the forum (or whatever Web-App it is):
    1. Disk I/O - if you haven't got enough RAM to keep EVERYTHING in RAM.
    2. Internet connection speed - unless you have many hundreds of megabits per second. For simple things, a modern single-core processor can push out data at 1GB/s and not really breaking into the middle of the CPU performance. Of course, processing the data more than just reading it and writing it to some portion of memory will make it a bit more than that, but it's unlikely that you have 1GB connection to the rest of the world.
    3. Thread/Process switching. When you have 10000 users, you will spend a lot of time switching from one user to another in the processing of the HTTP requests. It is likely to be a LARGE proportion of the CPU processing time to just keep all threads turning over. Let's say you have a 16 core machine, each core would handle 625 processes. Let's say each user does 1 request every 4 seconds [we're assuming it's forum, not a gaming server], then we have 4/625 seconds between each task-switch on each CPU. That's one process switch every 6.4 millisecond. That's not bad, but you also have to consider that there may be more to it than that: There are likely more than one thread/process per user - a PHP client, a database thread, appache itself. Reading the disk will not help either, as it makes another task-switch.

    Having a large cache on the processor will help the code-execution, but highly unlikely to contain something useful for the next thread when it comes to data.

    --
    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.

  13. #28
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by lruc View Post
    For a forum about this size, would CGI or PHP be faster? I cant see any forum I make getting any bigger than this.
    Ugh. Stop asking that, CGI can mean either Perl, PHP, some other or native code (for example C++). PHP in most cases uses CGI (SAPI is an alternative, but I doubt it's used more).
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  14. #29
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Quote Originally Posted by maxorator View Post
    PHP in most cases uses CGI (SAPI is an alternative, but I doubt it's used more).
    It is, if by SAPI you mean mod_php. If you mean IIS ISAPI, that's different.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  15. #30
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Quote Originally Posted by maxorator View Post
    Ugh. Stop asking that, CGI can mean either Perl, PHP, some other or native code (for example C++). PHP in most cases uses CGI (SAPI is an alternative, but I doubt it's used more).
    Right sorry about that. I mean CGI with C when I say that.
    Fried chicken for everybody!
    -Kernel Sanders

Page 2 of 3 FirstFirst 123 LastLast
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, 07: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, 11:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21