graywolf
graywolf

Reputation: 7470

FastCGI or HTTP server for C++ daemon behind nginx proxy

For high performance application accessible over web interface, would it make sense to implement/reuse some http server or go with fastcgi? I was convinced that fcgi would be correct choice, but I come across https://ef.gy/fastcgi-is-pointless and now I'm not so sure..

HTTP doesn't allow handling multiple sessions at one time, but that could be solved with spawning multiple deamon and let nginx act as balancer. But it would probably be much easier to test.

On the other hand, fcgi seems like having all necessary high-performance parts already in place (multiplexing requests in one process, therefore easier to implement cache, ...).

Does HTTP have any advantage over FastCGI aside from being easier to debug?

NOTE: Security is not so much of an issue since either fcgi or http will run behind nginx proxy.

Upvotes: 8

Views: 1889

Answers (2)

On the other hand, making your C++ application a specialized Web server (e.g. with libonion or Wt library, or even POCO) would make it quite easy to debug. Both can be used in a session aware way and will deal with the nitty-gritty details (caching, chunked encoding, transport-compression, ...). I guess (but don't know) that their HTTP performance might be slightly lower (both libraries are probably not as optimized as nginx is rumored to be). And they probably are best suited with a few dozens (or perhaps hundreds) of simultaneously active users, not thousands of ones (but I don't know, and never used them with that much users...).

And perhaps you might have real user cases for that (it really depends what the application is actually doing, and if you have users running Linux or some other POSIX systems...)

BTW, if you know (or want to learn) Ocaml, you might even use ocsigen; if you know Scheme or some other Lisp, consider HOP; if you are willing to learn a new language consider OPA (or maybe Haxe). All of these beasts enable you to easily mix server-side and browser-side computations.

Upvotes: 2

Galimov Albert
Galimov Albert

Reputation: 7357

Acting as HTTP server will force you to implement some things which is unrelated to your app's business logic. This includes but not limited to: keep-alive, chunked encodings, decoding forms data and many other little or big things. I'd prefer to stick with fastcgi since its requires less knowledge about transport-level protocol.

Upvotes: 9

Related Questions