How do you represent multi-process logical entities in OTP?

I would use dedicated supervisor for each logical component (I guess you mean by logical: http-workers, manager, dispatchers). Each of those would have supervisor over one of those classes. I like it, because I can benefit from additional tools to control it (count children, see it in i().Etc.) and it nicely separates the system.

I would use dedicated supervisor for each logical component (I guess you mean by logical: http-workers, manager, dispatchers). Each of those would have supervisor over one of those classes. I like it, because I can benefit from additional tools to control it (count children, see it in i().Etc.) and it nicely separates the system.

Gproc mentioned by @MinimeDJ and sync/async stuff is completely different thing. I think it is not the best architecture if you need in system you described to use gproc. Redesign it to have as much as possible stateless layers.

E.g. In stead of maintaining dispatchers = push model, try pull model = pull tasks from back-end machine. This solution makes queues stateless, you get rid of dispatchers and if anything goes wrong backend layer puts task again in some queue.

Moreover Managers are just reduced to API to queues and some stats collectors. Load of back-end workers is measured and controlled (localy!) in each of those heterogeneous back-end modules.

Hm, interesting suggestion (the pull model). Thanks, I'll think over it. – loxs Nov 9 at 7:19.

From very above we also have a system that consists of many special blocks and our first architecture was something similar to yours. Instead of HTTP we used RabbitMQ which I believe much more convenient in terms of messages exchange. But before the final release we understood that it will be a real challenge to maintain the whole system in production.So, we redesigned it again.

Now we represent each logical block as a process gen_server. Each process has a unique name and lives in gproc. Since gproc can live on many nodes we have very easy to manage fault tolerant system.

So, I would say, that we have Manageable Object Model (we call it MOM coz we really love it). So, for me your system seems to be overcomplicated. I don't know if my answer is useful at all, but sometimes it worth to think about your system in a way you never expected at the beginning.

I hope you will find a way to manage it in an easy way.

I am in exactly the opposite ship right now. I first designed the system in the way you suggest (have one process per logical entity). But it starts to become too complicated.

I have especially too many problems with "when to block and when not". So I feel it's time to have several processes. Some that can run without ever blocking (thus the whole entity is operational and can receive requests) and some that can block when they need, so that they can manage their job better.

– loxs Nov 4 at 19:19 To avoid blocking I use only cast-s. So far seems that it works. – MinimeDJ Nov 4 at 20:35 It works when you use it only for simple stuff.

But when you need to wait for responses, it quickly becomes messy. – loxs Nov 4 at 20:43 Sure, you rae right. This is why I try to avoid long-transactions.

Actually, next week we have to introduce purchase processes that are kind of long-transactions. So, it will be interesting challenge. – MinimeDJ Nov 4 at 16:21.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions