FastCGI library for Go

679 views
Skip to first unread message

Max

unread,
Jun 29, 2013, 1:54:31 PM6/29/13
to golan...@googlegroups.com
I wish to make Go app as front end for web request and run PHP as FastCGI to process some requests.

Right now we have NGINX+PHP and I wish to replace NGNIX with Go app.

Is there library to run FastCGI/PHP from Go?

Following class allows Go to run as FastCGI server


But I wish GO to be client and use PHP as FastCGI server.

Thank You

Kiki Sugiaman

unread,
Jun 29, 2013, 3:13:51 PM6/29/13
to golan...@googlegroups.com
Do you want to put your Go app in front of PHP?

AFAIK there's no package that facilitates this in the std lib, but I found this from Google: https://gist.github.com/wofeiwo/3727055

I understand that you have your reasons, but I'd say you're doing it the hard way. It's easier to put your PHP in front of Go and have it call http/json-rpc into Go in the backend.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Max

unread,
Jun 29, 2013, 5:33:28 PM6/29/13
to golan...@googlegroups.com
Thank You!

Why do you think it is hard way? I think it is interesting to see how NGNIX compares to Go

Carlos Castillo

unread,
Jun 29, 2013, 11:31:51 PM6/29/13
to golan...@googlegroups.com
Well, you can make a pretty decent web-server with Go. Attempting to use NGINX as a general purpose programming language, not so much. Sure it depends on how you weight it, but I declare Go the winner ;-)

Kiki Sugiaman

unread,
Jun 30, 2013, 12:23:39 AM6/30/13
to golan...@googlegroups.com
Well, you probably can write a simple http or rpc server in Go in <10 minutes using available, stable libraries (and writing the client in php can't be that hard).

I don't know how long it will take you to write an fcgi client in Go and the server/responder in php using that snippet, but I'm guessing it's a little longer since fcgi is a more delicate protocol than http/rpc.

Go can do what Nginx can't. But what Nginx can do, it will do it faster than Go.

Max

unread,
Jun 30, 2013, 3:44:23 PM6/30/13
to golan...@googlegroups.com
> Go can do what Nginx can't. But what Nginx can do, it will do it faster than Go.

Ok. I expect Go to be slower then NGNIX as well but I do not know if it is 20% slow, twice slower or 10 times slower.
Also I expect it to consume more memory.

NGNIX is very fast. Even smallest cloud instances or Intel Atom servers are able to utilize 1Gbit without encryption.

If Go will do 300-500 mbit when nginx does 1gbit then it make  sense. 
(Cloud instances often have real 20-100mbit connection. When Hypervisor is connected to 1Gbit)

Also I expect Go consume more memory and it is still not clear how much more.


Interesting how Go encryption performance compares to NGNIX encryption.

FastCGI client must understand that FastCGI server has 8, 10 or 16 processes and it will not provide extra one if requested.


So design of such system may include 1 channel. 
RequestHandlers read for FastCGI connection from channel and after request is processed FastCGI connection is released by sending it back to same channel.


May be there must be second channel for dead connections.


Seems like there is no production ready solution right now.

I have seen similar code but on google code

This one looks to be later version. I seen references that version of that code on google code has some bug.


This code has following lines

this.mutex.Lock()
defer this.mutex.Unlock()

I guess it is not the Go way to handle concurrency.
May be that code is ported FastCGI java servlet.

I am still looking for some mature code that is used in production by someone.
Reply all
Reply to author
Forward
0 new messages