2

I want to convert my web application prototype (PHP server side) to a C++ solution. This has already been decided. I've been on Wikipedia, Google, and SO to determine the best way to to this.

I've already decided on Linux and Apache (or custom server).

What I think I've learned is that this can be done multiple ways. In order of the speed or efficiency you will get.

  1. Write the Server
  2. Write an Apache Module
  3. Write it to use Fast CGI
  4. Write it to use CGI

I have about 1400 lines of PHP so my web app is small. I also know that CS courses in web typically have the students write a basic web server as lab. Fast CGI claims to be faster than CGI as the name implies..and I've heard that a module is fastest as it has a tighter integration with Apache. Writing your own server would probably be the fastest as it would be application specific instead of all purpose.

I'm trying to put together a project I can finish in under a year and keep the code base under 6000 lines or so.

What is the fastest way to do this that is reasonable?

Related SO Posts

C++ Web Libraries

Similar SO

Community
  • 1
  • 1
  • What kind of web application is it? – Basile Starynkevitch Feb 10 '12 at 17:05
  • You should add Pion too in the list. and another question I'd like to add, can things like `Pion`, `Wt`, `CppCMS` handle high traffic as Apache ? – Neel Basu Feb 10 '12 at 17:09
  • A large international classifieds company based in Sweden uses Apache modules, and most of their backend is written in C. – Some programmer dude Feb 10 '12 at 17:10
  • If you accept something else than C++, you could consider http://opalang.org/ or http://ocsigen.org/ or https://github.com/davidmoreno/onion – Basile Starynkevitch Feb 10 '12 at 17:11
  • I am assuming that you are doing this due to performance issues. If that is the case make it future proof and use apache modules. – Ed Heal Feb 10 '12 at 17:12
  • @Ed..can you expand on that ? –  Feb 10 '12 at 17:13
  • I can't be all that helpful on which technique to use on the server but you might be interested in Facebook's HipHop [link](https://github.com/facebook/hiphop-php) to help you with translating the code from PHP to C++. I've never tested it myself but figured it might be of some help. – h00ligan Feb 10 '12 at 17:14

4 Answers4

2

I don't have sufficient privileges to comment on a question, so putting my comment as an answer.

Considering that you've already built the prototype in php and if you're concerned about php's runtime performance, use hiphop for php! while deploying. Developing an apache module in c/c++ has quite a steep learning curve.

sanjivr
  • 991
  • 8
  • 12
2

I'd start with a FastCGI handler on nginx - it is really fast and CGI is a very stable API. Writing your own server may be a nice learning experience, but I am not sure you'd be able to make it nearly as performant as nginx or Apache.

Nemanja Trifunovic
  • 24,346
  • 3
  • 50
  • 88
  • Small note, even though, FastCGI is the correct direction it is very basic thing to start, you generally need a good library to handle many aspects of Web development. – Artyom Feb 19 '12 at 09:55
1

I'd strongly recommend to go with CppCMS.

  1. FastCGI support (and not FastCGI only)
  2. It was designed for performance in the first place.
  3. All tools needed for web development.
  4. The technology is already proven as high performance technology and that is already used on numerous web sites.

Disclosure: I'm the author of CppCMS

Small notes:

Write the Server

Why there are plenty good web servers that do the job well.

Write an Apache Module

You become tied to specific technology

Write it to use Fast CGI

This is the best approach as it web server independent and designed to run the user applications.

Write it to use CGI

CGI is good for small, rarely executed tasks. Not for high performance applications.


Note: web development is quite complex task, so using framework helps you to work on your business logic rather then dealing with small details

Artyom
  • 31,019
  • 21
  • 127
  • 215
-1

I have to agree with one of the commenters. C++ might not be the best choice, and you should probably get your work done more quickly using Opa or similar languages.