<div dir="ltr">Hi,<div><br></div><div>I am trying to learn Erlang by implementing a small Queueing Server.</div><div><br></div><div>What have I done so far?</div><div>I have created a basic websocket server using cowboy.</div><div><br></div><div>I am trying to implement a Queue which <b>all processes</b> can access.</div><div><br></div><div>I have used lists which can act as queues.</div><div><br></div><div>The basic insert function looks like this:</div><div><div>Queue(Q) -></div><div>        receive </div><div>               Msg -></div><div>                    Queue(lists:append(Q,[Msg]))</div><div>        end.       </div></div><div><br></div><div>To create a Queue called "Q_1"</div><div><br></div><div>> <span style="color:black;font-size:12px;line-height:1.1em;background-color:rgb(249,249,249)"> pg2:create(<<"Q_1">>).</span></div><div><span style="color:black;font-size:12px;line-height:1.1em;background-color:rgb(249,249,249)">>  P = </span><font color="#000000"><span style="font-size:12px;line-height:13.1999998092651px">spawn(test,Queue,[[1]]). % spawn queue and insert 1.</span></font></div><div><font color="#000000"><span style="font-size:12px;line-height:13.1999998092651px">>  </span></font><span style="color:rgb(0,0,0);font-size:12px;line-height:13.1999998092651px">pg2:join(<<"Q_1">>,P).</span></div><div><font color="#000000"><span style="font-size:12px;line-height:13.1999998092651px">>  P ! 2.</span></font></div><div><font color="#000000"><span style="font-size:12px;line-height:13.1999998092651px">>  P ! 3. % add some elements to queue.</span></font></div><div><br></div><div>to retrieve the elements from the named Queue "Q_1":</div><div>1. I use [Px|_]=pg2:get_members()</div><div>2. then I would do something like: Px ! POP_ELEMENT</div><div><br></div><div><br></div><div>Is there a better or more scalable way of doing this?</div><div><br></div><div>Will this work when a lot of clients are connected( around 60), having a insert rate of 100k elements per hour?</div><div><br></div><div>Any help is appreciated :)</div><div><br></div><div><br></div></div>