Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by
reshown by

Getting started with Ring. I am most familiar with web development in php, in which the php application is booted afresh on every request, which is proxied to by the web server, e.g. apache.

That of course means it is not possible that the php application itself can maintain any in-memory state (PHP enforcing a "shared nothing" architecture). So, I do note that in other languages such as java and Clojure the server is a long running process and there is therefore an option for global state. I aim to stick to 12-factor principles, though, and so I understand application state should be avoided, as if I was programming in php, perhaps.

I've got initial awareness about the reloaded workflow and such like. Of course, that makes sense in many cases.

However, since I am aiming that the web app I now write have no global state, would that mean I don't actually need a reloaded workflow (and hence lein ring would be enough - just to reload the code, not the state).

I wonder if there is anything I am missing. e.g. what if I change a config variable, maybe that counts as 'state', and would require a reload. Yes, I'll test this myself in due course to find out.

But just looking for any general tips / discussion on these points to help get off on the right foot.

1 Answer

0 votes
by

A "Ring" webserver's state might include such stuff as the port number, the Jetty object that's listening to the port, the client pools for webservices and connection pools for old-fashioned databases, the Lucene spelling index that your program builds from a text file every time it starts... and perhaps some catastrophically ill-advised caching of stuff from databases. You would generally not expect to keep much info about active users of the website in the server state, since in a multi-server hosting situation visitors might travel from one server to another.

...