Erlang/OTP Forums

Author Message

<  Open Telecom Platform (OTP)  ~  Which OTP behaviour to use

nicks
Posted: Fri Dec 25, 2009 5:02 pm Reply with quote
Joined: 25 Dec 2009 Posts: 9
Hi all,

I am implementing my first system in Erlang and have come quite a way, when I realized that I should be using OTP to build robust system, but I believe there is not enough documentations.

My system is a simple TCP client/server, with every new TCP message, I spawn a new process, which must *do something*. (In the end I am aiming for 20-40K messages/sec)

I have one supervisor process, while one worker process listens to incoming TCP socket, which in turns spawns new processes on the fly.

I also need to implement a simple FSM on worker process.

My question would be, which OTP behaviour I should be using? Do I need to combine OTP Supervisor,Gen_Server,Gen_Fsm? Or is only one of it is sufficient for my needs.

Thanks :)

Nick
View user's profile Send private message
hao
Posted: Fri Jan 08, 2010 4:16 pm Reply with quote
User Joined: 20 Aug 2007 Posts: 18 Location: Uppsala, Sweden
I think combination of application, supervisor, gen_server and gen_fsm will do good to your system. Here is a pretty good tutorial on building a non-blocking TCP server using OTP principles, thanks to the author Serge Aleynikov. It is quite similar to the system you are building as well as your design idea. So have a look and enjoy! Wink

http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles

PS: This tutorial is from Documentation->Tutorials in this website. There are plenty of good tutorials out there which you can learn a lot from.
View user's profile Send private message Send e-mail MSN Messenger
MathewBracken
Posted: Wed Feb 24, 2010 9:22 am Reply with quote
Joined: 24 Feb 2010 Posts: 3
Good implements.I think combination of application, supervisor, gen_server and gen_fsm will do good to your system.Thanks

Penny Stocks
View user's profile Send private message
ericdesouza
Posted: Wed Mar 10, 2010 11:50 am Reply with quote
Joined: 09 Mar 2010 Posts: 1
Maybe you really want to use gen_fsm. That behaviour is usually chosen front-ends for protocols, where the protocol have certain states and need to handle requests differently depending on what state it is currently in.

But back to gen_server, we use gen_server for its features. It subscribes to system events for code-loading and gives you the code_change callback. It causes sasl-reports on crashes. You get a well known structure that helps code maintenance. Most importantly, it implements a well designed protocol for synchronous calls.

It is hard to say if OTP behaviors are right for you in this instance.

_________________
r4i gold per dsi
View user's profile Send private message Send e-mail
wuji
Posted: Fri Aug 24, 2012 8:18 am Reply with quote
User Joined: 10 Aug 2012 Posts: 654
m watch over the patient and provide support. When families families [h2]cheap polo shirts[/h2] families aren't worried, they don't do so well."Deeply Religious Parents
Reluctant to Cease Medical CareSome Religious Beliefs May Lead to to cheap polo shirts to Sick Kids' Receiving 'Futile' Care: StudyBy LIZ NEPORENT, ABC
Medical UnitAug. 14, 2012— Arthur Caplan, the head of the the cheap designer *beep* the division of medical ethics at NYU Langone Medical Center,
a case of a man who had beaten his six-month-old six-month-old cheap authentic air jordans six-month-old child to death. It was a horror the mother
could not accept.A deeply religious woman, she pushed the doctors doctors cheap polo shirts doctors to do more, telling them that God would intervene
all
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum