[racket] Can't find how to use stateless servlets.
2011/5/7 Rahul Kumar <rahulsinner at gmail.com>:
> There are considerations listed in the references for stateless servlets.
>> First, this process drastically changes the structure of your program. It
>> will create an im-
> mense number of lambdas and structures your program did not normally
> contain. The per-
> formance implication of this has not been studied with Racket.
> So this is implicit? Right? No code changes on the user side.
Yup, you may have also noticed that compiling takes about twice as long.
And my most recent paper compares the performance of the
continuations. The difference is a wash.
Jay
>> Second, the defunctionalization process is sensitive to the syntactic
>> structure of your pro-
> gram. Therefore, if you change your program in a trivial way, for example,
> changing a
> constant, then all serialized continuations will be obsolete and will error
> when deserializa-
> tion is attempted. This is a feature, not a bug! It is a small price to pay
> for protection from
> the sorts of errors that would occur if your program were changed in a
> meaningful way.
> Ok, I get that.
>> Third, the values in the lexical scope of your continuations must be
>> serializable for the con-
> tinuations itself to be serializable. This means that you must use
> define-serializable-
> struct rather than define-struct, and take care to use modules that do the
> same. Simi-
> larly, you may not use parameterize, because parameterizations are not
> serializable.
> Haven't tried with struct yet; doesn't look like a big issue.
>> Fourth, and related, this process only runs on your code, not on the code
>> you require. Thus,
> your continuations—to be serializable—must not be in the context of another
> module.
> Again, serialization issue.
>
>
> On Sun, May 8, 2011 at 7:12 AM, Rahul Kumar <rahulsinner at gmail.com> wrote:
>>
>> Thanks Jay.
>> Worked like a charm. For anyone else fighting with the same issue, the
>> only change needed is the `#lang web-server` in-place of `#lang racket` in
>> the code sample - `#:stateless? #t` is already there.
>> Out of curiosity, since I didn't need to make any code changes to make
>> stateless work, is there any reason to run stateful servlets? The only
>> concern I see is the default stuffer which does disk writes - that too if
>> the urls are large. Nothing a fast disk and short ulrs can't mitigate.
>>
>>
>> On Sun, May 8, 2011 at 6:57 AM, Jay McCarthy <jay.mccarthy at gmail.com>
>> wrote:
>>>
>>> Stateless servlets must be written in the #lang web-server language.
>>>
>>> Once you write them that way, if you want to start a server that
>>> launches them, you need to use #:stateless?
>>>
>>> Unless you have both pieces, it won't work.
>>>
>>> Jay
>>>
>>> 2011/5/7 Rahul Kumar <rahulsinner at gmail.com>:
>>> > Hi,
>>> > What do I need to do to run a stateless servlet?
>>> > Consider the following example taken from the web tutorial. I just
>>> > added
>>> > `#:stateless? #t` while starting.
>>> > #lang racket
>>> > (require web-server/servlet
>>> > web-server/servlet-env)
>>> > ; start: request -> response
>>> > (define (start request)
>>> > (show-counter 0 request))
>>> > ; show-counter: number request -> doesn't
>>> > ; Displays a number that's hyperlinked: when the link is pressed,
>>> > ; returns a new page with the incremented number.
>>> > (define (show-counter n request)
>>> > (send/suspend/dispatch
>>> > (lambda (url)
>>> > (response/xexpr
>>> > `(html (head (title "Counting example"))
>>> > (body
>>> > (a
>>> > ([href ,(url
>>> > (lambda (req)
>>> > (show-counter (add1 n) req)))])
>>> > ,(number->string n))))))))
>>> > (serve/servlet start
>>> > #:port 7070
>>> > #:servlet-path "/"
>>> > #:listen-ip #f
>>> > #:stateless? #t)
>>> >
>>> > This doesn't work. I am looking at the web server reference but I can't
>>> > find
>>> > a proper example.
>>> >
>>> >
>>> > _________________________________________________
>>> > For list-related administrative tasks:
>>> > http://lists.racket-lang.org/listinfo/users
>>> >
>>>
>>>
>>>
>>> --
>>> Jay McCarthy <jay at cs.byu.edu>
>>> Assistant Professor / Brigham Young University
>>> http://faculty.cs.byu.edu/~jay
>>>
>>> "The glory of God is Intelligence" - D&C 93
>>
>
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93