Optimizing for CGI

28 views
Skip to first unread message

Eric Schultz

unread,
Jan 22, 2014, 10:38:21 AM1/22/14
to perl...@googlegroups.com
Good morning...

I'm starting to build a web app, and so far I've been using very basic modules like CGI::Simple but I've also looked at some frameworks like Dancer, Mojolicious, and of course Kelp. Kelp seems to benchmark the fastest of the three.

But since my environment is going to be primarily CGI (i.e.: shared hosting) I'm wondering if a framework is going to impose too much overhead since the app will be re-launched at every request. 

Is there some optimization I can to so that only the bits required to respond to the request are loaded? Is Kelp aware of it's context and can it lazy-load or can I write it in such a way to only load the code as required?

I'm expecting two types of requests:
  1. Single-Page-App to load the client side, this won't be static since some elements of the page (like menus) could change given certain contexts (this could potentially be handled on the client-side though); and
  2. AJAX requests to manipulate data from the client side.
So if a client requests a page then I don't want to go through loading the entire app just to return a bit of HTML. Similarly, if the client makes an AJAX request for some data I don't want to load the entire Kelp app just to respond to a single request.

Thanks,

Maurice Aubrey

unread,
Jan 22, 2014, 2:00:37 PM1/22/14
to perl...@googlegroups.com
Hi Eric.

On Wed, Jan 22, 2014 at 7:38 AM, Eric Schultz <er...@schultzter.ca> wrote:
> Good morning...
>
> I'm starting to build a web app, and so far I've been using very basic
> modules like CGI::Simple but I've also looked at some frameworks like
> Dancer, Mojolicious, and of course Kelp. Kelp seems to benchmark the fastest
> of the three.
>
> But since my environment is going to be primarily CGI (i.e.: shared hosting)
> I'm wondering if a framework is going to impose too much overhead since the
> app will be re-launched at every request.

Are you sure your host doesn't support anything other than traditional CGI?

Kelp is built on top of Plack, and Plack has adapters for all sorts of
different servers (see, for example, Plack::Handler::Apache2,
Plack::Handler::FCGI, etc.)

Maurice

Stefan Geneshky

unread,
Jan 22, 2014, 2:10:28 PM1/22/14
to perl...@googlegroups.com
Eric,

If your web host *only* supports CGI, then you're better off sticking to CGI. Using Kelp (or any other Perl web framework) as a CGI script doesn't make any sense, and it will impose too much overhead.
I would recommend you to talk to your host and see if you can get Plack::Handler::FCGI or another Plack adapter, like Maurice said in his email.
Also, there are plenty of web hosts that are not too expensive, which will give you root shell access. So, I would recommend that you look into finding another host.

Regards,
Stefan


On Wed, Jan 22, 2014 at 7:38 AM, Eric Schultz <er...@schultzter.ca> wrote:

Eric Schultz

unread,
Jan 22, 2014, 2:11:12 PM1/22/14
to perl...@googlegroups.com
Yeah, they're pretty adamant about only supporting CGI on their shared hosts. 

--
Headed for the second star to the right and straight on 'til morning...


  Read more at 2FatDads

Stefan Geneshky

unread,
Jan 22, 2014, 2:13:55 PM1/22/14
to perl...@googlegroups.com
I do hope that your hosting is provided for free then.
You can get root shell access server for $9.99/month nowadays. Maybe even less.

Maurice Aubrey

unread,
Jan 22, 2014, 2:37:11 PM1/22/14
to perl-kelp
On Wed, Jan 22, 2014 at 11:11 AM, Eric Schultz <er...@schultzter.ca> wrote:
> Yeah, they're pretty adamant about only supporting CGI on their shared
> hosts.

It sounds like they may not be very interested in hosting applications
then? Might be worthwhile to check out some alternatives.

One of the great benefits of Plack is it defines an interface (PSGI)
that abstracts away all the particularities of each web server
environment. So if your app becomes more popular, for example, you
could switch to a new provider and a totally different webserver
environment and your app should require no changes. You're going to
lose that flexibility if you go with CGI.

Maurice
Reply all
Reply to author
Forward
0 new messages