<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pavel Chlupáček on Medium]]></title>
        <description><![CDATA[Stories by Pavel Chlupáček on Medium]]></description>
        <link>https://medium.com/@chlupacek?source=rss-27163f9ea1f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_45Iy4eVUQNZcMFY.</url>
            <title>Stories by Pavel Chlupáček on Medium</title>
            <link>https://medium.com/@chlupacek?source=rss-27163f9ea1f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 17:00:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chlupacek/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Concurrency proposal for Restcomm Media Server MGCP stack]]></title>
            <link>https://medium.com/@chlupacek/concurrency-proposal-for-restcomm-media-server-mgcp-stack-d796ae0fd310?source=rss-27163f9ea1f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d796ae0fd310</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Pavel Chlupáček]]></dc:creator>
            <pubDate>Fri, 27 May 2016 14:26:28 GMT</pubDate>
            <atom:updated>2016-05-27T14:26:28.014Z</atom:updated>
            <content:encoded><![CDATA[<p>With recent attempts to improve MGCP implementation of RMS (Restcomm Media server), I would like to propose concurrency model described further in this document. The proposal is very rough idea, and is subject of further detailed work. Proposal assumes implementation language is Java 8.</p><p>This document is intended for people that are familiar with RMS internal structure.</p><h4>Terminology</h4><ul><li>`Program` — Set of instructions that form simple business logic (MGCP/Transaction/Endpoint interactions) that is not bound to particular concurrency environment. Essentially, program shall behave very similar if run in highly concurrent environment and in single thread.</li><li>`Singleton Program` — `Program` that runs in the system exactly once. It starts on system startup and terminates when it is done.</li><li>`Strategy`-A description how program may be run (executed) with respects to the threads</li><li>`Scheduler` — A primitive allowing to Schedule run of the program at configurable periods</li><li>`Queue` — Asynchronous Queue. Allows to enqueue messages (commands) that may be eventually dequeued later<br> by program. Messages are dequeued on different thread than the one that enqueued them. Queue guarantees messages to be dequeued in same order how they have been enqueued. Queue may have configurable bound, that when reached will not allow any further enqueue messages by either asynchronously blocking or rejecting them to be enqueued.</li><li>`Topic` — Asynchronous Topic. Allows to publish messages, that may be received by arbitrary subscribers. Each subscriber is guaranteed to received all message in topic in same order as they have been published. Like `Queue` subscribes dequeue their messages on different thread than they are published.</li><li>`Signal` — Asynchronous Signal. Allows to signal change of the state to one or more subscribers. Allows to react on state changes, monitor state updates. Similar to AtomicRef except it is fully asynchronous and allows subscription for changes of the values.</li><li>`Thread` — Unless otherwise mentioned, Thread further is not new `java.lang.Thread`, but instead is one of the threads managed by Scheduler or Strategy. It is up to their decision, if running computation needs to be allocated to new `Physical` thread. For the purpose of this document new `Thread` is submit of Program to be run by `Scheduler` or by `Strategy`.</li></ul><h4>Thread strategy</h4><p>The proposed MGCP stack is suggested to be run in several constant thread pools:</p><ul><li>Scheduler Thread Pool — for scheduling timing information. Implemented as Scheduled Executor Service</li><li>Command Thread Pool — for scheduling commands and MGCP requests / responses. Suggested implementation is ForkJoin Daemon Thread Pool.</li><li>Media Thread Pool — High priority Fork-Join daemon thread pool for performing media operations</li></ul><h4>Basic structure</h4><p>Basic proposed structure has three layers:</p><ol><li>MGCP Network Stack</li><li>Transactions</li><li>Endpoints</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*aHpCEaJifXDtxP0F3MQKqg.png" /></figure><h4>MGCP Network stack</h4><p>Responsible for asynchronous send/receive of MGCP Messages to/from Control Agent (CA), possible multiple CA. Once UDP Datagram is received, then if the Message is response then, `TransactionRegistry` is consulted to enqueue response to current open Transaction, or Request for new Transaction is submitted to `TransactionRegistryQ`.</p><p>Any Transaction (see below) may queue MGCP Message to Output Q, and that message is taken, serialized and sent to its final destination as UDP datagram. Serialization possibly may be subject to be before message is enqueued, to eventually increase the parallelism.</p><h4>Transactions</h4><p>Transactions are short-lived `Programs` that live in scope of single MGCP Transaction. Once each Transaction is started then it registers with TransactionRegistry and once it terminates it unregisters itself from that registry.</p><p>Transaction is either created by RMS (Request and then Response like NTFY) or by CA (like CRCX). Transactions are created by submitting into CreateTXQueue which is monitored by CreateTx Singleton Program. That program always creates Tx and forks in to be run on other thread.</p><p>TransactionRegistry is implemented as `Signal&lt;Map&lt;Int,Queue&lt;TxCommand&gt;&gt;&gt;` so it is possible to monitor it for changes, and as such any part of the RMS can safely get stable quick view of open transactions.</p><p>If Transaction program involves activity of two endpoints (i.e. CRCX ivr/1 bridge/1) than it is responsibility of transaction program to await confirmation of activity from both endpoints or perform cleanup at any endpoint shall transaction fail halfway.</p><p>Transaction programs submits Commands to Endpoints by Either looking up the endpoint in Endpoint Registry, and then submitting to that Endpoints queue, or submitting endpoint creating request to `CreateEndpoint Queue`.</p><p>Transactions created by Request, always issue Response to MGCP Stack Output Queue. Transactions created by RMS always issue request to MGCP Stack Output Queue, and then awaits Response from the CA.</p><p>TransactionRegistry is furtherMore managed by `TransactionTimeoutScheduler`, that fires timeouts in transaction to eventually resend unacknowledged Requests, and/or Timeout transactions.</p><h4>Endpoints</h4><p>Endpoints are compare to Transactions more complex program and represents RMS core functionality. Endpoint is uniquely identified by its id (i.e. `ivr/1`) and are stored in EndpointRegistry.</p><p>Likewise Transactions, Endpoints are referenced in `Signal&lt;Map&lt;String,Endpoint&gt;&gt;` and similarly created by issuing request to EndpointCreate Queue. Endpoint is an interface, that exposes its Command Queue and Audio Topic.</p><p>Endpoints programs perform all audio related tasks and are also responsible for controlling RTP/UDP/TCP Channels for media.</p><p>There are multiple endpoint types, and describing them is out of scope of this document.</p><p>Just to clarify the interaction between endpoints. Endpoints will use Topic where they will submit all their output audio. Topic usually have at least one consumer, and that is RTP media network channel, but may have other endpoints (i.e. conferencing) for mixing different input streams into one.</p><p>Interactions between endpoints is solely via Endpoint Registry, that exposes Topic, and Endpoint Command Queue.</p><p>Very detailed schema of Endpoint Interaction is below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UiBbBR2PtKTyZi-nOCSGpA.png" /></figure><h4>Program</h4><p>Program in this proposal is essentially defined as Task&lt;Void&gt; that can be run by its `run` method. Unless the `run` is executed, Program may be composed by composing multiple `Tasks` together, possibly with concurrency primitives like: fork, race, async etc. w/o any side effects or computations to be run stack safely. For the functional folks `Task` is similar to `IO monad` and `Free monad` but with concurrency control, suspend able computations and exception handling.</p><p>This was very rough introduction of ideas, and I would welcome any further comments to it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d796ae0fd310" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Distributed RestComm Media Server at Spinoco]]></title>
            <link>https://medium.com/@chlupacek/distributed-restcomm-media-server-at-spinoco-fd3ac48409d0?source=rss-27163f9ea1f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd3ac48409d0</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Pavel Chlupáček]]></dc:creator>
            <pubDate>Mon, 02 May 2016 11:50:07 GMT</pubDate>
            <atom:updated>2016-05-02T15:00:46.739Z</atom:updated>
            <content:encoded><![CDATA[<p>Here at <a href="http://www.spinoco.com/">Spinoco</a>, we are developing an application that allows teams to communicate and share information and ideas with their colleagues and customers.</p><p>Unlike many seemingly similar application, ours has a built-in telephony part, allowing users to make and receive traditional telephone calls either from a desktop PC or from any common VoIP phone. The application has complex built-in IVR and queuing policies, and boasts some nice features, such as on-demand call recording, and predictive dialing.</p><p>Our team has extensive experience with the various VoIP offerings on the market, and therefore we have been looking for a solution that will allow us to build a scalable and distributed telephony system. Unlike the currently available solutions, we have been looking for something that satisfies the needs of a modern, internet-enabled telecommunication solution.</p><p>Some of the requirements that we wanted to fill were scalability, elasticity, and the ability to run on commodity hardware (ideally compatible with hosting providers of virtualization solutions). We also wanted to add in a lot of customization to our customers’ specific needs.</p><p>After evaluating the many options available, we had chosen <a href="https://github.com/RestComm/mediaserver">RestComm Media Server (RMS)</a> as a viable candidate for us. Even though the Media Server has decently aged code base, it fits nicely to our development and deployment stack. The picture below shows the final solution that we have deployed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*HZhnFfXiryMruSg8mIJmEA.jpeg" /><figcaption>Spinoco RMS deployment</figcaption></figure><p>The RMS integrates just like our common server, it is just the plain old java server. As a control plane we have developed control agent (CA) that talks SIP/MGCP to traditional telco hardware and via our protocol through Apache Kafka servers to rest of the Spinoco servers.</p><p>Essentially we always deploy RMS + CA in pair to form 1:1 relationship. Although it may sound a little bit complicated, the deployment is automatically handled by Kubernetes from Google, which we use as our deployment stack..</p><p>That allows us to add/remove any number of RMS/CA pairs as we need, this is the fully elastic solution, that makes the scalability and reliability neat and straightforward. In fact the single cluster here is limited just by network capacity and by the throughput of <a href="http://kafka.apache.org/">Apache Kafka</a>.</p><p>Now as the picture shows, we also get a sort of free WebRTC/SIP gateway with almost unlimited scalability. Because RMS supports ICE protocol, we are able to directly point our WebRTC clients to RMS, and leave SIP where it belongs - at the core network.</p><p>Our experience with this setup has so far been quite reasonable. We obviously had to go through some pitfalls, and issues, but overall we believe that we have created very simple solution to complex problem, using commodity hardware with virtual endless scalability, that we can tightly integrate to our stack.</p><p>One of the aims we looking at in future is to strengthen RMS. Its software could be perhaps described as “legacy” and we would benefit from modern concurrency techniques in it.</p><p>I&#39;ll followup on this article with more specific technical details how we achieved the clustering of RMS/CA, with details about Apache Kafka and its role in our signalling. We also use a pretty neat Scala concurrency library under the hood, which may be interesting to describe in further articles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd3ac48409d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>