Is ruby CGI the good way

Hi,

We have a simple API plan, it does the standard web request/handle flow:
get requests from users, do something with DB queries, return the
results to users.

I know well about CGI and ruby’s CGI module. So it’s quiet easy to write
the API with CGI module with Apache as webserver.
But, does CGI have slow performance? What’s the good alternative?
Sorry I know nothing about Rais, and I don’t think we need rails to run
for this simple service.

Thanks.

CGI module is fairly crap. (Slow performance, has to load a Ruby
interpreter against every request, etc.) If you have a simple API, it’s
probably better to choose something much more lightweight and not Ruby,
depending on how complex it is.

Julian

Subject: is ruby CGI the good way
Date: gio 04 apr 13 10:53:34 +0900

Quoting Ken P. ([email protected]):

We have a simple API plan, it does the standard web request/handle
flow: get requests from users, do something with DB queries, return
the results to users.

I know well about CGI and ruby’s CGI module. So it’s quiet easy to
write the API with CGI module with Apache as webserver. But, does
CGI have slow performance? What’s the good alternative?

What do you need as performance? Lots of hits per second? Because, for
simple in-house use, with a few people making queries now and then,
Webrick does an excellent job. Webrick is the web server included in
the official Ruby code. Sadly, you won’t find much documentation
around, but once you have overcome the initial learning step, things
go quite smooth - all you have to run is your Ruby process.

Then, Ruby has a VERY VAST offer of solutions for web coding, even for
high-throughput sites. But it’s a world that requires quite a long
learning process. You may want to read about Rack:

http://rack.github.com/

which is a common interface to various webserver engines, and maybe
Sinatra:

http://www.sinatrarb.com/

which is a simpler, more straightforward web framework than rails, and
is sitting on Rack.

Carlo