How does Scala Elevator manage the state?

I am very impressed that Lift 2.0 leads to a table with Actors and StatefulSnippets, etc., but I'm a little worried about the excessive memory of these things. My question is twofold:

  • How does Lift determine when garbage collects state objects?
  • What is the size of the page request page tracking?

If the web caterpillars are dancing across the site, are they going to open enough state objects to drown out the modest VPS (512 M)? The question is very obvious depending on the application, but I'm curious if anyone has any real shapes that they can throw at me.

+6
scala lift stateful
source share
2 answers

Raises information about the state of a state in a session, so after the destruction of a session, the state associated with this session disappears.

During the session, Lift tracks every page that the state is highlighted on (for example, a mapping between the ajax button in the browser and the function on the server), and you have a heartbeat in the browser. Functions for pages that have not seen a heartbeat for 10 minutes are not displayed, so the JVM can collect them. All this is customizable, so you can change the heart rate, life expectancy, etc., but in practice, the default work very well.

In terms of a blast session, yes ... this is a secondary issue. Popular sites (including http://demo.liftweb.net/ ) experience this. The sample code (see http://github.com/lift/lift/tree/master/examples/example/ ) defines the sessions created by a single request and then is abandoned and expires earlier. I run demo.liftweb.net with a size of 256 MB heap (which would fit in a 512 MB VPS), and sometimes the number of sessions increased by more than 1000, but it quickly decreased for search engine traffic.

+12
source share

I think that the question about the memory area was once met somewhere on the mailing list, but I cannot find it at the moment.

Garbage collection takes place after some downtime. However, there is a wiki example that uses some of the best heuristics to kill sessions generated by web crawlers.

Of course, for your own project, it makes sense to check memory consumption with something like VisualVM when you create a couple of sessions yourself.

+1
source share

All Articles