# Multi Process Racket (or even distributed)

**URL:** <https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785>\
**Category:** General\
**Tags:** multi-process, distributed\
**Created:** [March 11, 2022, 1:43pm UTC](https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785 "2022-03-11T13:43:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)\
**Post date:** [March 11, 2022, 1:43pm UTC](https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785/1 "2022-03-11T13:43:45Z")

</div>

_I wrote this in response to [another question](https://racket.discourse.group/t/logging-to-a-single-file-from-multiple-loggers/781), but also to get these things out of my head and written down. I am also curious about other interesting similar or related tools._

Personally I don't have done a lot of multi process racket in a practical sense, but I have looked into the options in the past, because it was interesting to me and I thought I could mention them here, to make this a sort-of overview.

# rackety multi process

- [Parallelism with Places](https://docs.racket-lang.org/guide/parallelism.html#(part._effective-places)) describes places, there are also distributed places on the same page for multiple machines. [os-threads, multi-machine]
- [loci](https://docs.racket-lang.org/loci/index.html) is a library by @pmatos that is similar to places but overcomes memory locking issues that can be observed with high core counts. [os-processes]
- tcp client-server (This could make sense if you don't want to use one of the places variants)
- [Syndicate (classic)](https://docs.racket-lang.org/syndicate@syndicate-classic/index.html) "Syndicate is an actor language where all communication occurs through a tightly controlled shared memory, dubbed the dataspace. [...]" _It seems that a new version of syndicate is in development, but it currently doesn't have a working documentation link, so I am linking to the classic version which seems more stable._
- [Goblins: a transactional, distributed actor model environment](https://docs.racket-lang.org/goblins/index.html) "Goblins is a quasi-functional distributed object system, mostly following the [actor model](https://docs.racket-lang.org/goblins/api.html#%28part._what-is-an-actor%29). Its design allows for object-capability security, allowing for safe distributed programming environments.[¹](https://docs.racket-lang.org/goblins/intro.html#%28counter-%28%29._%28gentag._1._%28lib._goblins%2Fscribblings%2Fgoblins..scrbl%29%29%29) [...]"

* * *

In general I would say when you want true multi-process, you still have something easier than dealing with multiple machines, but you are already very close to multi-machine solutions and I think you should be thinking about, whether you truly only need one machine or also multiple machines.

While with one machine you don't have to worry about network latency and uptime and all that stuff, when you build something that can run on multiple machines you often can create it, in a way so that it also easily runs on one machine. The reverse is more difficult, when it is done as a secondary thought.

# general tools

For example [ZeroMQ](https://zeromq.org/) allows you to do messaging between applications running on the same or different machines, or also communicate between applications written in different programming languages. Racket seems to have 3 different [ZeroMQ Packages](https://pkgd.racket-lang.org/pkgn/search?q=zeromq) I haven't tested those, so I am not sure which works best.

I have some experience using [redis](https://redis.io/) (with other programming languages) and I liked it a lot! When your problem can be mapped to redis, I think you should really consider it, because I found it to be quite a lot of fun to use it. [redis packages](https://pkgd.racket-lang.org/pkgn/search?q=redis) (but if you really only need to merge message streams it may be a bit much)

[Kafka](https://kafka.apache.org/) also seems very interesting, so far I haven't had an excuse to use it, or look deeper into it, it seems @bogdan is working on a package for it. [Kafka package](https://pkgd.racket-lang.org/pkgn/package/kafka)

* * *

Overall I like the simplicity and flexibility I would get from just writing my own tcp server with racket, especially in regards to being able to add new message types when the need arises. ZeroMQ seems very valuable if you have to interact with a multitude of programming languages. Redis if your problem fits it and you can make use of its features and for example use it as a cache (but it can do a lot more).

---

<div class="post-metadata">

**Author:** ![Laurent.O](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/laurent.o/32/18_2.png) [@Laurent.O](https://racket.discourse.group/u/Laurent.O)\
**Post date:** [March 13, 2022, 1:22pm UTC](https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785/2 "2022-03-13T13:22:22Z")

</div>

There are also [os-threads](https://docs.racket-lang.org/foreign/Operating_System_Threads.html). I haven't used them myself, but I wonder whether the GC would make it hard to scale to many cores.

Currently I tend to start independent racket processes from the command line, but this requires one Racket VM per job, which is a lot (say with 10 processes, that's 10x one VM, about 2-4GB). Sharing some of this would be nice.

---

<div class="post-metadata">

**Author:** ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)\
**Post date:** [March 13, 2022, 2:20pm UTC](https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785/3 "2022-03-13T14:20:04Z")

</div>

> [@\[ann\] kafka-lib](https://racket.discourse.group/t/ann-kafka-lib/790):
>
> I’ve written a pure-Racket client for Apache Kafka. It’s far from feature-complete at this point, but the basics are there, so [check it out](https://github.com/Bogdanp/racket-kafka) if you’re interested in using Kafka with Racket. Feedback welcome!

---

<div class="post-metadata">

**Author:** ![Laurent.O](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/laurent.o/32/18_2.png) [@Laurent.O](https://racket.discourse.group/u/Laurent.O)\
**Post date:** [March 14, 2022, 2:24pm UTC](https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785/4 "2022-03-14T14:24:30Z")

</div>

Another pretty interesting third party library: [Distributed Places](https://docs.racket-lang.org/distributed-places/index.html) to run jobs on different physical machines via ssh. It seems to have lots of features.

---

<div class="post-metadata">

**Author:** ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)\
**Post date:** [March 14, 2022, 4:31pm UTC](https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785/5 "2022-03-14T16:31:20Z")

</div>

I agree that it is interesting, but it is part of the main distribution and I saw it as the distributed variant of places. So mainly wanted to say that it doesn't seem third party to me.

---

<div class="post-metadata">

**Author:** ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)\
**Post date:** [March 17, 2022, 4:29pm UTC](https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785/6 "2022-03-17T16:29:36Z")

</div>

> **[Marketplace: A language for network-aware programming](https://blog.racket-lang.org/2013/05/marketplace-a-language-for-network-aware-programming.html)**
>
> \_posted by Sam Tobin-Hochstadt\_ We are happy to announce the release of Marketplace, a new programming language for building functional network programs. Marketplace combines two fundamental ideas in a new way: nested virtual machines and...

[Marketplace: Network-Aware Programming](https://tonyg.github.io/marketplace/index.html)
