When should I use Perl CGI instead of PHP (or vice versa)?

前端 未结 8 1420
悲哀的现实
悲哀的现实 2021-01-07 23:48

For hobby purposes, I have a shared space on a hosting server that is providing, as many of them are, both PHP and Perl CGI. I have read on several places that CGI scripts

8条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-08 00:22

    Whether you use PHP or Perl is moot from a scaling perspective much in the way that the difference between a webapp written in PHP and C is moot. If the difference really mattered, we'd all be writing C, or assembly.

    PHP is slow, but that isn't stopping Wikipedia, Facebook, and Yahoo from using it extensively.

    There are two major reasons it doesn't matter, from a scaling perspective, which language you choose:

    1. Use a caching reverse proxy like Squid. By offloading most of apache's workload, you can cut your CGI invocation load dramatically.
    2. Scaling your web tier is easy. It's scaling your database tier that's hard. You can always add another webserver to the farm. If you can serve 1000 requests per second with mod_php, and 500 requests per second with a CGI, if it's cheaper and faster for you to develop the CGI, do it. You'll need twice as many web heads, but either:
      1. You're in the bottom 90% of the web, and only really need one webserver anyway.
      2. You're in the top 10% of the web, and need multiple webservers -- but you've got enough traffic to justify the additional cost.

    Pick the language that you and your team can develop in most efficiently.

提交回复
热议问题