<p dir="ltr">That sounds like a similar technique to node's cluster module (ignoring the very different languages and server implementations ie async io v threads)</p>
<div class="gmail_quote">On 17 Jul 2014 15:50, "Brian Adkins" <<a href="mailto:racketusers@lojic.com">racketusers@lojic.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[forgot *again* to reply-all and only sent this to Jay initially - resending to group]<br>
<br>
Thanks for the response Jay.<br>
<br>
I may have glossed over the parallelism & concurrency aspects a bit too much when I first read those sections in the Racket Guide. I now see in 20.1 re: Futures:<br>
<br>
"The level of parallelism available from those constructs, however, is limited by several factors, and the current implementation is best suited to numerical tasks."<br>
<br>
and in 20.2:<br>
<br>
"The place form creates a place, which is effectively a new Racket instance that can run in parallel to other places, including the initial place."<br>
<br>
"Places" appears to be similar to my current approach of having multiple Ruby/Rails processes handle web requests. In the case of Ruby/Rails, it's a very inefficient use of memory, i.e. the amount of RAM needed to fully utilize all cores is *much* higher than it should be when spinning up multiple app server processes that each load the entire Rails framework. Each Rails process is essentially single-threaded.<br>

<br>
I was hoping to gain a big improvement of Ruby/Rails with Racket, and that may be possible even with the current implementation (both Ruby & Rails are performance-challenged), but can you give me some idea of the level importance multi-core performance is in the Racket community moving forward? I'm taking a fairly long term perspective with Racket, so the "roadmap" is as important to me as the current implementation.<br>

<br>
I'm referring to Racket in general, not just the web server.<br>
<br>
I haven't done much research or testing yet, so maybe a combination of Places and Threads will be sufficient for my needs. Maybe one Place per CPU core w/ multiple threads to keep the CPU busy while some threads are blocked on I/O requests.<br>

<br>
Thanks,<br>
Brian<br>
<br>
On Jul 16, 2014, at 10:17 PM, Jay McCarthy wrote:<br>
<br>
> It wouldn't have a big impact on the server. The big question is how<br>
> to effectively use multi-core in Racket programs generally.<br>
><br>
> Futures are really only good for numerical codes that stay in the JIT,<br>
> which doesn't sound like most Web programs. That said, it is trivial<br>
> to implement:<br>
><br>
> #lang racket/base<br>
> (require racket/future<br>
>        web-server/servlet-env<br>
>        web-server/http)<br>
><br>
> (define (fib n)<br>
> (if (< n 2)<br>
>   1<br>
>   (+ (fib (- n 1))<br>
>      (fib (- n 2)))))<br>
><br>
> (define (start req)<br>
> (touch<br>
>  (future<br>
>   (λ ()<br>
>     (response/xexpr<br>
>      `(html<br>
>        (body<br>
>         (p "It's "<br>
>            ,(number->string<br>
>              (fib (random 20)))))))))))<br>
><br>
> (serve/servlet start)<br>
><br>
> Boom! That's a servlet that uses multi-core to handle every request...<br>
> of course, it probably doesn't pay in this or most other programs.<br>
><br>
> Places are for more coarse-grained things and you can pass file<br>
> descriptors, so it's feasible to have a TCP accepter that feeds work<br>
> to a group of places servicing the requests. However, places must not<br>
> use mutation to communicate higher-order values (they can communicate<br>
> flat values like numbers with mutation), so they couldn't share<br>
> continuations. It would be trivial to use serializable continuations<br>
> or to implement a continuation manager that stored all the<br>
> continuations in a single place. Session affinity doesn't really make<br>
> a lot of sense in the continuation context, fwiw.<br>
><br>
> My guess is that you could spend less than 100 lines to implement the<br>
> continuation manager and the place-based worker setup. (This is based<br>
> on the normal server setup just being 127 lines and the manager<br>
> interface being implemented in as little as 40 lines.) This might be<br>
> worth it.<br>
><br>
> Jay<br>
><br>
><br>
> On Wed, Jul 16, 2014 at 4:09 PM, Brian Adkins <<a href="mailto:racketusers@lojic.com">racketusers@lojic.com</a>> wrote:<br>
>> I haven't looked into the Racket web server much yet, so I'd like to understand the implications of this.<br>
>><br>
>> My experience is with stateless http app servers (primarily with Unicorn Ruby servers at the moment), so firing up a number of worker processes and having something like nginx proxy to them works well to fully utilize all cores.<br>

>><br>
>> I think I read that the Racket web server makes use of continuations, so I expect some sort of process affinity would be necessary, where a given user's requests are always proxied to the same worker process - is that right? Is it common to use multiple web server processes in Racket web apps?<br>

>><br>
>> In your estimation, what is the feasibility of adding multi-core support to the Racket web server? For example, is it reasonably feasible and on the current roadmap, or would it require massive changes to the web server?<br>

>><br>
>> Thanks,<br>
>> Brian<br>
>><br>
>> On Jul 16, 2014, at 8:42 AM, Jay McCarthy wrote:<br>
>><br>
>>> It does not use multiple cores if they are available.<br>
>>><br>
>>> Jay<br>
>>><br>
>>> On Wed, Jul 16, 2014 at 7:02 AM, Sean Kemplay <<a href="mailto:sean.kemplay@gmail.com">sean.kemplay@gmail.com</a>> wrote:<br>
>>>> Hello,<br>
>>>><br>
>>>> I am interested in the racket web server for some micro services. Just<br>
>>>> wondering if by default it runs across multiple cores or if it is restricted<br>
>>>> to one due to threads in racket.<br>
>>>><br>
>>>> Regards,<br>
>>>> Sean<br>
>>>><br>
>>>><br>
>>>> ____________________<br>
>>>> Racket Users list:<br>
>>>> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
>>>><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> Jay McCarthy<br>
>>> <a href="http://jeapostrophe.github.io" target="_blank">http://jeapostrophe.github.io</a><br>
>>><br>
>>>         "Wherefore, be not weary in well-doing,<br>
>>>    for ye are laying the foundation of a great work.<br>
>>> And out of small things proceedeth that which is great."<br>
>>>                        - D&C 64:33<br>
>>> ____________________<br>
>>> Racket Users list:<br>
>>> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> Jay McCarthy<br>
> <a href="http://jeapostrophe.github.io" target="_blank">http://jeapostrophe.github.io</a><br>
><br>
>          "Wherefore, be not weary in well-doing,<br>
>     for ye are laying the foundation of a great work.<br>
> And out of small things proceedeth that which is great."<br>
>                         - D&C 64:33<br>
<br>
<br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div>