Web app server

Q&A's, tips, howto's

Web app server

Postby prime » Tue Aug 06, 2019 8:44 am

Hi all,

I'm very new to newLISP and this forum, so apologies if this has been answered before:

Can newLISP be used to create a standalone http web app server?
e.g. using the TCP sockets (in which case the html protocol would need implementing)
or does the -http mode already allow this, i.e. if I provide a .lsp file for the server entry point which can then call other .lsp scripts and implement routing etc. (as per node.exe)

Many thanks in advance.
prime
 
Posts: 2
Joined: Thu Aug 01, 2019 10:12 am

Re: Web app server

Postby ralph.ronnquist » Tue Aug 06, 2019 11:21 am

Can newLISP be used to create a standalone http web app server?

The answer to that one is of course "yes"; newlisp, with -http, provides a basic HTTP server for a small range of file types, including ".cgi" which it handles in a similar way to apache2. I.e., the ".cgi" file is an executable, and possibly a script in whatever scripting language.

There are however a number of caveats in having newlisp as the web service front-end. Especially that it's single threaded, and will handle one request at a time to completion. Also, the front-end process is a separate process from any ".cgi" processes, and the front-end doesn't provide any session management or "web app instance persistance".

The HTTP processing is built-in, and without hooks in the front-end processing apart from the usual command-event. So all in all it's easy to use for developing an app, and perhaps some personal, "odd" HTTP responders, while you'd move to a more capable front-end (e.g. nginx) for any more serious service.

On the other hand, newlisp is quite handy for response scripting as .cgi files, especially for services that don't need instance persistence.

That's 2c from me :)
ralph.ronnquist
 
Posts: 213
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: Web app server

Postby prime » Tue Aug 06, 2019 11:47 am

Hi Ralph,

Thank you very much for your quick and informative response ;o)

It is persistence I am seeking, I'm investigating if newLISP can act as a http web app server behind a proxy server, indeed I'd like to be able to spin up multiple newLISP 'servers' (on separate ports) and use nginx to load balance between them...allowing for concurrent connections.

I'd prefer not to use .cgi as I'd like to make MySQL connections once, not every time the script is called. I tried to download your 'ranwar.tgz' link earlier, thinking this may be what I am looking for....do you think it might be?

An alternative is to create a http server using the inbuilt socket library, however, there is clearly already http protocols going on...its how do I tap into those for a persistent web app server?

Best regards ;oD
prime
 
Posts: 2
Joined: Thu Aug 01, 2019 10:12 am

Re: Web app server

Postby ralph.ronnquist » Tue Aug 06, 2019 12:56 pm

As I remember, ranwar.tgz is an attempt to implement a front-end in newlisp to allow concurrent request handling, and "emulate" persistence for newlisp app scripts by means of the shared memory facility. It starts a sub process for every request, and is designed for a notion "app instance" by means of shared memory.

Then it also includes a good support framework for using newlisp to make templated HTML, which probably is the stronger aspect in that "mess" :)

In short, the "ranwar" infrastructure supports app instance data persitence, but not process persistance; pretty much the same as django through gunicorn off an nginx server, but with a nicer scripting language. If you have a keen interest in using newlisp, then it shouldn't be too hard to make good use of the infrastructure. That also gives you full control of all the facets in the HTTP handling pipeline, although at the expense of performance.

In fact, I have a real-life example still running, as an internal, back-office server with a mixture of complex computations, and remote host interactions, a flexible web app utility for a handful of users.

Ralph.
ralph.ronnquist
 
Posts: 213
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron