<?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[FLY Tech - Medium]]></title>
        <description><![CDATA[Stories on Engineering, Product Development and Design by Flywheel Sports. - Medium]]></description>
        <link>https://medium.com/flywheel-tech?source=rss----217bf8e263bb---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>FLY Tech - Medium</title>
            <link>https://medium.com/flywheel-tech?source=rss----217bf8e263bb---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 19:55:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/flywheel-tech" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cloud-scale file transfer]]></title>
            <link>https://medium.com/flywheel-tech/cloud-scale-file-transfer-370d69120fa?source=rss----217bf8e263bb---4</link>
            <guid isPermaLink="false">https://medium.com/p/370d69120fa</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Carlos Justiniano]]></dc:creator>
            <pubDate>Mon, 06 Aug 2018 14:50:31 GMT</pubDate>
            <atom:updated>2018-08-24T15:54:58.824Z</atom:updated>
            <content:encoded><![CDATA[<p>Using NodeJS, Redis, Docker and AWS Lambda</p><p>Recently, I had an opportunity to build a system for transferring large numbers of files from one cloud Content Delivery Network onto another. This post describes the key components and the overall architecture.</p><p>The file content in question was nothing less than our entire video library for <a href="https://shop.flywheelsports.com/">FlyAnywhere</a> — the live and video on-demand fitness service we created at <a href="https://www.flywheelsports.com/">Flywheel Sports</a>.</p><p>During the past year, we’ve amassed a sizable video library. Copying that library from one CDN to another would be a time-consuming operation — but one that would eventually complete — even if it took a few days to transfer. However, more important than a one time transfer is the fact that an ideal solution would need to continually transfer content after each newly recorded class. This is where transfer time equates to fresh content availability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CjnsMYobxZu5b6nVZ-nZQA.png" /><figcaption>A Live broadcast at our FlyLive Studio in NYC</figcaption></figure><p>I wish I could say that the transfer operation was simply a matter of invoking an SCP/SFTP file transfer. But there was no such luck. Files in the primary CDN are stored in an <a href="https://en.wikipedia.org/wiki/Object_storage">object storage container</a> (think S3) and there’s no direct access to a directory structure per se — just a flat bucket with path-like filenames.</p><p>Additionally, each video is stored as an <a href="https://en.wikipedia.org/wiki/HTTP_Live_Streaming">HLS</a> stream — a live streaming format consisting of multiple manifest files and lots of individual audio and video segments stored as files. A typical 30-minute video can consist of thousands of segments due to the number of multi-channel video streams required to support <a href="https://bitmovin.com/adaptive-streaming/">adaptive streaming</a>.</p><p>So the task at hand required reliably transferring an entire collection of videos with millions of individual file segments. Terabytes of data, in essence, a highly-scalable file sync operation.</p><p>Naturally, it’s the “reliably transferring” phrase above that requires special attention. File transfers fail due to broken and or timed out network connections. A blind copy just won’t do. Each file needs to be properly tracked and accounted for.</p><h4>Enter Lambdas</h4><p>The source files that needed to be copied are already in the cloud and the destination is AWS S3 for use with CloudFront. Both are ideal scenarios for servers which are also already in the cloud. My first consideration was simply to use a Docker Swarm cluster to manage a collection of microservices. Such an approach would rely on multiple container replicas to ensure distribution across available machine CPU cores. Then I thought, “<em>Why not try lambdas?</em>” After all, file transfer tasks are what’s known in computer science as an <a href="https://en.wikipedia.org/wiki/Embarrassingly_parallel">embarrassingly parallel</a> problem - given that each file can be individually transferred.</p><p>AWS <a href="https://aws.amazon.com/serverless/videos/video-lambda-intro/">Lambda</a> seemed like an ideal solution to perform the transfer at scale. Lambda’s offer scalable compute resources without the need for server provisioning and maintenance. Enter the so-called server-less revolution.</p><p>Quickly thereafter the <a href="https://en.wikipedia.org/wiki/Dopamine">Dopamine</a> rush hit… <em>whaaaat?</em> <em>I could have thousands of machines simultaneously moving files? Sign-me-up!</em></p><h4>Introducing FLAnts</h4><p>Using Lambdas, the process behaves like a swarm of ants carrying objects back to an ant colony. And given that the files in question originate from our Flywheel Live production studio — I decided on the name FLAnts (FlyLive Ants). Cheesy — I know! Fortunately, I’m not in marketing…</p><p>FLAnts consists of a command line tool and three microservices. Each one built using NodeJS. The fifth module is the lambda code — also written in Javascript for NodeJS. The microservices run in a Docker Swarm cluster.</p><p>Let’s take a closer look at the underlying process. The first order of business required determining which content needed to be copied. A process called the class-scanner pulls class metadata from our cloud MongoDB and performs basic validation on each class. Because not all classes stored in the database are actually broadcasted. Some are test classes, others are aborted classes — imagine a director yelling <em>“cut!”</em>.</p><p>For every validated class, the class-scanner pushes a job onto a Redis job queue.</p><p>A second process is the class-crawler. The process gets its name from the similar process of <a href="https://en.wikipedia.org/wiki/Web_crawler">web crawling</a>, an underpinning of Internet search engines. The class-crawler, pops a job from the Redis queue and performs the task of reading each classes HLS manifest file and crawling it to collect a list of individual HLS segment file names. Each segment’s metadata is used to populate another job queue which identifies each file that needs to be copied. Each resulting job can be distributed to one of thousands of Lambda instances. It’s also worth noting that the class-crawler doesn’t have to be a single process. On a large scale multi-core machine we fire off one per CPU core. And each pulls atomically from the job queue. Amazon has sports car-class machines featuring 72 and 128 cores. It is a great time to be in tech!</p><p>A third process called, segment-transfer, pops transfer jobs from the Redis queue and dispatches them to lambda instances. The role of the segment-transfer process is to act as an orchestrator or traffic cop of sorts. Also like the class-crawler, the segment-transfer process can run as multiple processes for all available CPU cores — across multiple machines.</p><p>Our forth and last process is called the aggregator. Its role is to process completed jobs and assemble them based on their respective classes. When all of the segments of a class have been processed, the transfer operation is deemed successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7XfNxl2cDSzRFBFna2muDA.png" /></figure><p>The diagram above shows the four process types which can either run on a large multi-core machine or across a number of EC2 instances. Each connects to a Redis instance for job queuing. The segment-transfer process is shown dispatching lambdas which in turn copy data from one CDN to another.</p><p>The reason for this overall approach is that any one of the four process types can fail and require a restart. That was especially true during the development phase and is a good example of <em>designing software with failure in mind</em>. That’s something that’s vital when building distributed systems.</p><h4>Message Queuing FTW</h4><p>As described above, all four processes have a very important feature in common: each relies extensively on message queuing. The class-scanner queues messages, the class-crawler, and segment-transfer both dequeue and queue messages. And the aggregator dequeues messages and generates a transfer report.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*p9VWGZOlbZwlirShHpxF-g.png" /></figure><p>A key reason for using message queuing is to control the flow of work between processes. Each process is blazing fast and it’s not uncommon to max CPU usage and blow through both memory and socket handles. It’s far better to queue messages and allow processes to consume them as fast as they can — but not faster!</p><p>Another significant benefit is that queuing allows for multiple instances of a particular task to participate in the message processing.</p><p>Additionally, queuing and the use of multiple process instances allows NodeJS-based applications to take full advantage of multicore machines.</p><p>Queues also assist in decoupling applications. In the illustration above each service type can have instances on the same and across networked machines; so long as the queuing service is accessible.</p><p>I chose to implement my processes using NodeJS and<a href="https://www.npmjs.com/package/hydra"> Hydra</a>. Hydra has built-in message queuing which sits on top of Redis. So implementing the above queuing couldn’t be easier. Here’s an example from the segment-transfer process.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48cd7391b47cfc826eab17ccdde7c8fb/href">https://medium.com/media/48cd7391b47cfc826eab17ccdde7c8fb/href</a></iframe><p>I only need to specify which service receives the job (using the to field) and include a bdy (body) object which contains the actual job details.</p><p>The aggregator service only needs to dequeue messages when it’s ready:</p><p>let message = await this.hydra.getQueuedMessage(&#39;aggregator-svcs&#39;);</p><p>The aggregator is responsible for dequeuing jobs messages which contain the result of each lambda instance’s file transfer.</p><p>I used the queuing features built into Hydra, but you don’t need to use Hydra to do something similar. See this <a href="https://gist.github.com/cjus/719d77dd9816115d94083234c293c18b">sample gist</a> showing the relevant Redis commands.</p><h4>Batching</h4><p>The segment-transfer service reads transfer jobs from a queue and dispatches them to lambda instances. Also, keep in mind that there are multiple segment-transfer instances (replicas) running.</p><p>Rather than attempt a massive lambda launch, each segment-transfer service reads 100 jobs and organizes them into a single batch. That results in 800 lambda invocations on an eight core machine with eight segment-transfer instances. That works out well given that by default there’s a maximum of 1000 concurrent lambda invocations. In practice I haven’t seen more than 500 simultaneous invocations due to the overhead of processing jobs into batches and launching lambda instances. Running twice the number of segment-transfer replicas per core would change that.</p><h4>Error handling</h4><p>Occasionally, a lambda instance will fail to perform a transfer — shocking I know! When that happens the issue can be attributed to a network socket break or timeout. However, this isn’t an issue, because the entire system relies on messaging queuing so it’s just a matter of re-queuing the failed job.</p><p>Each job message contains a retry field which starts at three. Each failed attempt reduces the count by one and should the count reach zero then the job is marked as a complete failure. This has never happened. The most I’ve seen is a single retry resulting in success.</p><p>This all works exceedingly well. However, re-queuing messages causes them to get pushed to the end of their job queues. So what ends up happening at run-time is that jobs don’t complete until much later in the process. I noticed this behavior when I added a web-based visualizer to the aggregation service.</p><p>The classical solution is to use a priority-based queue. A priority queue would have allowed me to re-queue jobs with a higher priority to ensure those jobs didn’t have to move the end of the line. Redis support this <a href="http://charlesnagy.info/it/python/priority-queue-in-redis-aka-zpop">using the zpop</a> operation, which is something I may later revisit. Yet another potential solution is to maintain a separate job queue for failed operations and pull from that queue before pulling from the main job queue. It’s a code complexity trade-off.</p><p>Instead, I simply maintained an in-process re-queue list and pushed those jobs onto the next batch operation.</p><h4>Visualizing the file transfer</h4><p>To better see the actual behavior of the overall system I decided to build a web-based visualizer. The thought of rendering each of those virtual ants (I mean lambdas) as they transferred file segments — definitely warranted a side-hack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*AUSPnLtpUj61DAbM7MTdUQ.gif" /></figure><p>I added a dashboard endpoint to the aggregator service to serve up a ReactJS single page app.</p><p>One challenge is that the dashboard could end up displaying the status of hundreds of video classes. Rendering that much data would be too slow - even using a virtual DOM.</p><p>I quickly realized that each file segment should not be a div but rather a single unicode text character.</p><p>Another important optimization used on both the front and backend is the use of <a href="https://en.wikipedia.org/wiki/Bit_field">bit fields</a>. Since a class can have 5000 segments I simply create a 5000-bit field string and further reduce the required size by sending data from the backend in hex string format. The front-end converts the hex string to a binary string which is then iterated to render 0 as ◯ and a 1 as ◉.</p><p>Also once a class video is completely transferred, the segment status display is turned off to further reduce the impact of page rendering. The NPM <a href="https://www.npmjs.com/package/bitset">bitset</a> package was helpful in this regard!</p><h4>Transfer speeds</h4><p>The speed of transferring files using this approach is absolutely staggering. In one of my earlier tests, the system transferred four terabytes of data in two hours and twenty minutes — that’s <a href="https://www.wolframalpha.com/input/?i=transfer+rate+for+4TiB+in+2+hours+and+20+minutes">roughly 523MB per second</a>!</p><p>And that’s nowhere near the maximum potential. Using both a larger multi-core or cluster of multi-core machines and a higher concurrent limit of lambda invocations would yield even higher transfer speeds. Granted there are costs involved so don’t try this at home.</p><p>This post describes an approach, but one which exceeded our initial expectations. Admittedly, the task at hand is almost tailor-made for lambda — but also shows how microservices and server-less technologies can be used together. There’s no reason you can’t have both!</p><p>—</p><p><em>Thanks for reading! If you like what you read, hold the clap button below so that others may find this. You can also </em><a href="https://twitter.com/cjus"><em>follow me on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=370d69120fa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flywheel-tech/cloud-scale-file-transfer-370d69120fa">Cloud-scale file transfer</a> was originally published in <a href="https://medium.com/flywheel-tech">FLY Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Light-weight Microservices using Redis]]></title>
            <link>https://medium.com/flywheel-tech/building-light-weight-microservices-using-redis-23f051624647?source=rss----217bf8e263bb---4</link>
            <guid isPermaLink="false">https://medium.com/p/23f051624647</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Carlos Justiniano]]></dc:creator>
            <pubDate>Wed, 23 May 2018 21:42:24 GMT</pubDate>
            <atom:updated>2018-08-06T14:47:58.677Z</atom:updated>
            <content:encoded><![CDATA[<p>This post is based on my <a href="https://youtu.be/z25CPqJMFUk">RedisConf18</a> talk by the same name. The goal here is to provide greater detail than was possible during the time allotted during my earlier presentation.</p><p>Hydra is a lightweight NodeJS library for building distributed computing applications such as Microservices. Our definition of lightweight is: light on external complexity and infrastructure dependencies — not light as in limited. Hydra’s claim to being light on infrastructure dependencies is due to its only external dependency being Redis.</p><blockquote>In the extremely unlikely event that you’re reading this and have never heard of Redis — then stop right here and visit <a href="https://redis.io/">redis.io</a>. You can return to this post at a later time.</blockquote><p>Hydra leverages Redis’s rich data structures to implement features required by non-trivial microservices. Features such as presence, service discovery, load balancing, messaging, queuing and more.</p><p>Hydra is also light in the weight sense. In fact, light enough to run on $5 Raspberry Pi Zeros. More about that <a href="https://medium.com/flywheel-tech/embracing-microservices-11750470ba31">here</a>.</p><p>Besides being light, Hydra is also one of the easiest ways to build microservices. While this post won’t be an introduction to Hydra, as there are plenty of good introductory resources <a href="https://www.npmjs.com/package/hydra#articles">here</a>, it will offer a deep dive into how Hydra leverages Redis to enable the construction of lightweight microservices.</p><p>A quick disclaimer is in order. The first is that the approach I’ll share in this post may not be a good fit for your projects. You may need heavier microservices. And that’s ok. The approach I’ll share here has been proven at Flywheel Sports and a host of other companies. I wrote an <a href="https://medium.com/flywheel-tech/embracing-microservices-11750470ba31">earlier post</a> detailing why we built Hydra and the role it played in the building of our nation-wide live video streaming service.</p><h4>What exactly is Hydra?</h4><p>Hydra is a NodeJS module which can be imported into JavaScript Node apps to empower them with microservice features. Hydra does this by leveraging Redis.</p><p>Here we see three microservices — each with a Hydra module which connects to Redis. In this model, most services don’t communicate with Redis directly. Rather the underlying Hydra module proxies to Redis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*ys4L3gYgubOfjuNKllPd2w.png" /></figure><p>Another point about this diagram is that Hydra is just another imported module — like the ones shown in green. Hydra is only shown in blue at the bottom to illustrate its presence and connection to Redis.</p><p>The Hydra module exposes a JS class interface with a total of 36 member functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*O7hWYBbdRYCMor5kD8yM8A.png" /></figure><p>This snapshot provides a sense of the ease of our abstractions. Member functions such as <em>findService</em> and <em>sendMessage</em> are pretty straightforward.</p><h4>How Hydra leverages Redis</h4><p>This slide from my RedisConf presentation shows a number of important microservice concerns. Each, is required by non-trivial microservices. We’ll examine, in detail, how Hydra uses Redis to implement each of these features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*0Qz_f4KqHt6JDXxjj8dpQA.png" /></figure><p>Keep in mind that the goal here is to show how it’s possible to do this — not to say that each approach is how you should implement the feature in your own services. A case in point is that while you can store your microservice configuration data in Redis or use Redis as a logger — it doesn’t mean that you should. At least not unless you know exactly what you’re doing and what the trade-offs are.</p><p>Also, keep in mind that you don’t need Hydra. Each of these features is made possible by Redis and you can certainly do this in your own apps.</p><p>A key point in what I’ll show you is that some of these features are only made possible when combined. For example, request and message routing depend on presence, health, service discovery and load balancing.</p><p>As you know, each of these features can be addressed using various infrastructure tools. However, a key goal with Hydra is to simplify building microservices while minimizing external infrastructure requirements. As you build your production-ready services you get to decide which Hydra features you need and which features you’ll get from other tools. It’s not an either-or proposition — but rather a matter of what you’re trying to achieve and how quickly you can get started.</p><p>That said, it is interesting to see how all of these features can be implemented just using Redis and your favorite programming language.</p><h4>Key space organization</h4><p>The first step in understanding how Hydra leverages Redis is to examine how it organizes the use of the Redis key space.</p><p>Hydra’s use of keys — consists of names with 2 to 4 segment labels separated by a colon character. The segments labels are named: Prefix, Service name, Instance ID, and type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*ZeSDgeW_vkCfUvbIzEryvw.png" /></figure><p>The Prefix segment allows for filtering Hydra vs non-Hydra keys. So if you make heavy use of Redis then being able to filter for specific keys is vital.</p><p>The Service Name segment aids in filtering keys of a particular service type. Examples would be an authorization, user or image processing service types.</p><p>The Instance ID segment allows filtering keys for a unique service instance. When running microservices you typically want multiple instances of a service type running. Each service instance is assigned a unique ID and being able to differentiate between them is useful.</p><p>Lastly, there’s the Type segment which is used to classify the purpose of a key. Not all of the segments are present in each key. For example, Service name and instance ID are not required in some keys.</p><p>Here’s an example of a key for the user service. We see the prefix which is <em>hydra:service</em> followed by the service name, in this case, “user-svcs”. Next, we see the unique instance ID. And lastly, we see that the type of this key is presence. So we say that presence information is stored at this key address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*GX-bQLC_mkKfHbYWa6DR2w.png" /></figure><p>A confusing point in our earlier description is that keys consists of names with 2 to 4 segment labels separated by a colon character. Yet, here we see <em>hydra:service</em> also being separated by a colon character. The thought there was that there might be another <em>hydra:other</em> types where <em>service</em> is only one of them. There is another inconsistency involving messaging which we’ll examine later. We’re planning to address these issues in Hydra 2.0 which will be a breaking change but cleaner internally.</p><p>We can enter the redis-cli and type Redis commands to view various keys. We’ll see examples of this through the remainder of this presentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*pRNzofX8gLEh338vP798jg.png" /></figure><p>A quick note about the redis-cli examples we’ll use: You’ll see the use of the keys command — this is shown for ease — internally Hydra uses the Redis scan command. For more about this see point #4 <a href="https://redislabs.com/blog/5-key-takeaways-for-developing-with-redis/">here</a>.</p><p>So to recap — Hydra’s use of keys is organized by segments which makes them easier to query. Furthermore, a consistent organization makes them easier to extend and maintain. As we continue we’ll see the role that keys play in the organization of each microservice feature. Let’s begin by examining presence.</p><h4>Presence</h4><p>In the world of microservices, the ability to discover services and to know whether a service is healthy and can be routed to is of paramount importance. Those features depend on knowing that a particular service instance is actually present and available for use. This is also required for features like service discovery, routing, and load balancing.</p><p>Once a second, Hydra updates the (TTL) time to live of its service key. Failure to so within a three second period will result in the key expiring and the host app being perceived as unavailable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*2Z4-k0QBGEjMGJY6rBZ_Og.png" /></figure><p>We can see here that the Redis commands used are “get” and “setex” which sets a key and an expiration.</p><p>We can query presence keys by using the “keys” command with a pattern match. Notice that there are three keys present. This tells us that there are three instances of the “asset-svcs” running.</p><p>If we attempt to retrieve the contents of one of these keys we see that it contains the instance ID.</p><p>And using the TTL command against the key shows us that it has 2 remaining seconds before it expires.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*Vg-E9EvtKaJJstuDnp0gMQ.png" /></figure><p>So to recap. Microservice presence can be managed using keys which auto-expire. Updating the key is done automatically by Hydra on behalf of the host service. Meaning it’s not something the developer does. Failure to update the key within 3 seconds results in the service being perceived as unavailable. That probably means the service isn’t healthy.</p><p>Which brings us to our next topic…</p><h4>Health</h4><p>Being able to monitor the health of your microservices is another important feature. Hydra gathers and writes a health information snapshot every 5 seconds.</p><p>You can check the snapshot for a quick view of an individual service instance’s health. And, the snapshots can be used by monitoring tools such as the HydraRouter dashboard.</p><p>So here’s what the health key looks like. Notice that the only new bit is the “type” segment identifying the key as being about health.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*pgEO0Q4vn_0kh-RY-XUMzw.png" /></figure><p>When we view the contents of the key we see that it contains a stringified JSON object. In this case, it’s for the “project-svcs”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*4WxbDhnJCRtCEkmEyhfvrA.png" /></figure><p>Unstringifying the JSON makes it easier to see what’s stored. It contains lots of useful information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*ZHEojR7j9L_89zaEXtzWLA.png" /></figure><p>So health information can be stored per service instance. It’s managed using a string key that contains stringified JSON text. And that information can be used by monitoring apps.</p><h4>Service Discovery</h4><p>Next, let’s consider service discovery, which is another must-have feature for any microservice architecture.</p><p>The ability to discover the IP and PORT location of a service by name greatly simplify communication. Other bonus points include not having to manage DNS entries or create fixed routing rules.</p><p>Service discovery information is stored in a Redis Hash with a type of “nodes” The use of a Hash enables blazing fast lookups. We use the Redis “hget”, “hset” and “hgetall” commands to work with the nodes hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*TRexpHPbbuIfg_oiQ2U4IA.png" /></figure><p>The following Redis operations can be used to implement service discovery. The first is a lookup for a particular service type. The second is a lookup for available instances. The third lookup, allows Hydra to retrieve information about a specific service instance.</p><p>We can see useful information such as the version of the service, the instanceID, IP address and Port and finally the host name. In this example, the hostname also happens to be the Docker container id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*QTcKaoxGjjSE1OPOChEoAA.png" /></figure><p>We can retrieve information about all available instances using the Redis “hgetall” command. This is how Hydra Router retrieves a list of services to show on its dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*6fbFR-juhdREAhOuDgh7SQ.png" /></figure><p>Let’s recap. Hydra queries using the servicename key segment in order to discover various bits of information about a service. Service details <br>can be managed using a Redis Hash which offers blazing fast service discovery</p><p>Next, let’s consider routes.</p><h4>Routes</h4><p>Routing both HTTP and messages such as Web Socket or PubSub — requires that routes be validated. Microservices can publish their routes to Redis. And as an example, HydraRouter uses the published routes to implement dynamic service aware routing.</p><p>Each service publishes its routes in a key of type “service:routes”. Here we see the key for the “asset-svcs” routes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*q25VnJlXOMrjERMRDzDhJg.png" /></figure><p>Service routes are stored in a Set structure. A good fit because you don’t want duplicate route entries. The SADD and SMEMBERS commands are used.</p><p>As an aside, Redis’s rich collection of data structures is one of the reasons that what I’m sharing with you is even possible.</p><p>Returning back to our routes. We can pull a list of routes using a key pattern. Here we see routes for a number of services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*0BvxCbkRF-Exn_k5quO-IQ.png" /></figure><p>We can use the “smembers” command to view the contents of a specific route set. BTW, the bracketed [get], [post] and [put] bits represent HTTP REST endpoints. For other messaging transports the use of the bracket method may be omitted.</p><p>So let’s recap. Each service publishes its routes to a Redis Set. Accessing an individual route reveals a collection of route entries for that service.</p><p>Routes are stored in Redis using a Set data structure which avoids duplicate routes. The published routes can be used to implement dynamic service aware routing. Next, let’s consider Load Balancing.</p><h4>Load Balancing</h4><p>As your application grows you’ll need to load balance requests among available service instances. This is accomplished with Redis using the service presence and routing features we’ve seen. At an application level, using Hydra, this is as simple as using the “makeAPIRequest” or the “sendMessage” call. Load balancing takes place inside those calls as Hydra uses routing and presence information to choose among available target instances.</p><p>A nice benefit is that during routing if a request fails on a particular instance, Hydra is able to retry other available instances before ending in an HTTP 503 server unavailable error.</p><p>As you can see here, load balancing relies on other features such as presence, service discovery and routes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*VybFMplNfGSRc87Zbsd_NQ.png" /></figure><p>To recap, load balancing requests among services can be accomplished using the Presence, Service Discovery and the Routing features we’ve seen. Redis Strings, Hashes and Sets make this possible. The whole is greater than the sum of its parts.</p><h4>Messaging</h4><p>Distributed services are forced to communicate with one another over an underlying network. HTTP Rest calls are probably most common, but socket messaging can be much more efficient. Messaging in Hydra is accomplished using Redis Pub/Sub channels and Redis implements Pub/Sub over socket connections.</p><p>Here’s an example key. Hydra uses the Redis “subscribe”, “unsubscribe” and “publish” commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*rq1zXe8UrhsH6n_euflL6g.png" /></figure><p>As an aside, the Hydra router is able to accept messages over HTTP and WebSockets and convert them to pub/sub messages.</p><p>To understand how this works consider two services, the “asset-svcs” and the “project-svcs”. Each service creates two keys, one using its service name and another using its service name and its instance ID. Each service listens to both channels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*ELssrpCLnB2YG-ryhki6uQ.png" /></figure><p>In most cases, you don’t care which instance of a service handles a request. In those cases, the channel without a specific instance ID is used.</p><p>Now, when you need to send a message to a specific instance the channel with an instance ID can be used. It’s important to note that hydra converts requests to a service name to one with a specific instance ID when it load balances. That ensures that only one instance handles a given message or request.</p><p>We can see a list of channel keys using the Redis pub/sub channels command. Notice that we have four keys here. The first key is the name of “asset-svcs” — shared by all instances of the asset service. Next, we see three additional keys with unique instance IDs. One for each of the three service instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*Exh4hSnww4AAlMLBFPok9g.png" /></figure><p>Continuing with our focus on messaging. In order to ensure interoperability between microservices, it’s essential to standardize on a shared format of communication. The universal message format is a <a href="https://github.com/cjus/umf/blob/master/umf.md">documented JSON-based format</a> which includes support for messaging, routing and queuing. These messages are stored in Redis as JSON stringified text.</p><p>Here’s an example UMF message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*A8kNOum0YG3_pIV9KJOcUw.png" /></figure><p>The “to”, “frm” and “bdy” fields are required and services are free to include their own custom fields in the “bdy” object.</p><p>Let’s see how this is used in practice.</p><p>On the left, the “client-svcs” sends a message to the “project-svcs”. Note that this only requires a UMF creation call and a send message call, shown here in yellow.</p><p>On the right — the “project-svcs” listens for messages and processes them as necessary. That’s accomplished using an event message listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*8ejg62xZPLft81dCmKp5VA.png" /></figure><p>Note that Hydra abstracts away the service discovery, load balancing, routing and pub/sub specifics. Sending and receiving messages only involves three member functions. It’s worth pausing here for a brief moment. Take a few seconds to consider what this example would look like using your favorite stack.</p><p>Let’s take a closer look. Send message works by parsing the ”to” field in a message to determine the destination service name. With the service name in-hand the next step is to check for available instances. With a target instance in-hand, the message is then stringifed and sent via the Redis “publish” command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*pvecaRUyztHQm5NgVTYeRQ.png" /></figure><p>Again we can list all the Pub/Sub channels in Redis. Messages can be sent via these channels and retrieved by listeners. So with a bit of programming code, we’re able to use Redis to route messages using a well-organized collection of channels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*lsJ7bhM1mIQ426HDhFwdnw.png" /></figure><p>In summary, it’s worth noting that messaging is eventually necessary because services are physically distributed. Redis enables messaging using its pub/sub features.</p><p>Standardizing communication enables interoperability between services. We also saw how easy communication can be at an application level when we abstract away the underlying service discover, load balancing, routing, and pub/sub specifics.</p><p>Next, let’s consider messaging queuing.</p><h4>Queuing</h4><p>Job and message queues are yet another important part of many non-trivial applications. Hydra uses Redis to maintain dynamic queues for each service type.</p><p>Service instances can then read their queues and process items.</p><p>The content of a queue message is a UMF message which follows the same format used for messaging. Again, interoperability is king!</p><p>Hydra automatically creates three queues per service type.</p><p>* A “received” queue<br>* An “inprogress” queue<br>* And an “incomplete” queue.</p><p>Because these are Lists we use the Redis “lpush”, “rpush”, “rpoplpush” and “lrem” commands.</p><p>Here’s a diagram showing the message flow between queues. The movement of items between queues is an atomic operation in Redis. So it’s safe regardless of how many microservices you have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*5DztGRxGDKeDUQRICGoV1A.png" /></figure><p>In this next example on the left, queuing a message is as simple as creating a UMF message and calling “queueMessage” to send it. The code on the lower right shows the image processing service dequeuing a message by calling “getQueuedMessage” and later calling “markQueueMessage” once it’s processed the message. How easy is that?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*rXgFOQFafSXtIU0PyppfQQ.png" /></figure><p>So to recap, sometimes, it isn’t feasible to expect an immediate response. In those cases, we just need to queue work for later processing. The Redis List data structure can be used as a message queue. Commands like “lpush” and “rpoplpush” with atomic operations make this feasible. Here again, we saw how easy basic queuing can be using higher-level abstractions.</p><h4>Logging</h4><p>Distributed logging is another vital feature of any microservice architecture. However, if you know Redis you might be appalled at the thought of using it as a distributed logger. And you’d probably be rightfully concerned. However, you could use it as a flight recorder. Where you only store the most serious errors and you limit the number of entries using “lpush” and “ltrim”. Then at least you would have a quick way of checking what might have gone wrong with your microservice.</p><p>Here is what the key looks like. Notice the key type is <em>health:log</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*TOr4QXBCxr5pYMNDinW8zw.png" /></figure><p>Here we see that the <em>health:log</em> key type is actually a “List” data structure. So we can use the Redis “lrange” command to view the flight recorder log <br>for the “imageproc-svcs”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*cESdv-AR4bjIDjNEGOHLEw.png" /></figure><p>Recapping: having logs on dozens, or worse, hundreds of machines isn’t feasible with microservices. Distributed logging is definitely the way to go. Using Redis you can build a light-weight logger to use as a flight recorder. Using the Redis List data structure and the handy “lpush” and “ltrim” commands make this possible.</p><p>And lastly, let’s consider configuration management.</p><h4>Configuration management</h4><p>Managing the configuration files for distributed microservices can be challenging. However, you can even use Redis to store configuration files for your services. We did this and it seemed like a good idea at the time. However, we’re starting to move away from it. As the core disadvantage is that storing configs in Redis makes Redis stateful and that’s less than ideal. But this is possible, so I’d like to share this with you.</p><p>Let’s see how this works. There is a configs key type which is a hash. The hash has a key consisting of the service version with a value set to the configuration data for that version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*6oGKQ2WcTSp1QyXdkSoUWQ.png" /></figure><p>Here’s a sample configuration. In our case, we used a command line tool called “hydra-cli”, which allowed us to push configuration files to specific service versions. All this did was create a hash entry with a key consisting of the service name and version with the file contents as its stringified value. Keep in mind that you can also use a shell script to drive the redis cli.</p><p>We can pull a specific version using the “hget” command and the version of the config.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*m1My23NlkvgFebrku3h_-A.png" /></figure><p>Let’s quickly recap, we saw how Redis can be used to store application configuration files. The Redis Hash data structure allows us to store configs for each service type. Each config entry is indexed by the service version label and the contents simply point to a stringified JSON config.</p><h4>Summary</h4><p>Wow, we’ve covered a lot. But in summary, what I’ve shared here is an approach that very heavily leverages Redis using JavaScript and NodeJS. However, there’s nothing preventing anyone from doing the same with other languages. And because <a href="https://www.npmjs.com/package/hydra">Hydra is open sourced</a> it can serve as a reference platform for such efforts.</p><p>I’m pleased to announce that we have a Hydra-inspired Golang version in development, which we hope to open source soon. We’re also considering a Java version.</p><p>So that’s how Hydra leverages Redis. And how we were able to both <a href="https://medium.com/flywheel-tech/embracing-microservices-11750470ba31">build <br>and launch our FlyAnywhere platform</a>.</p><p>—</p><p><em>Thanks for reading! If you like what you read, hold the clap button below so that others may find this. You can also </em><a href="https://twitter.com/cjus"><em>follow me on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23f051624647" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flywheel-tech/building-light-weight-microservices-using-redis-23f051624647">Building Light-weight Microservices using Redis</a> was originally published in <a href="https://medium.com/flywheel-tech">FLY Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embracing Microservices]]></title>
            <link>https://medium.com/flywheel-tech/embracing-microservices-11750470ba31?source=rss----217bf8e263bb---4</link>
            <guid isPermaLink="false">https://medium.com/p/11750470ba31</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Carlos Justiniano]]></dc:creator>
            <pubDate>Wed, 23 May 2018 20:50:16 GMT</pubDate>
            <atom:updated>2018-09-09T01:04:10.758Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a second in a series of posts which share how we built the FlyAnywhere platform. In this post, I’ll describe how we embraced microservices, and why we built Hydra: a light-weight library for use with distributed computing projects.</p><h4>Migration to Microservices</h4><p>Before joining Flywheel Sports I learned of their existing monolith written in PHP and Drupal. To its credit, the monolith supported the growth of Flywheel from a one fitness studio business to 42 studios across the US and a membership of over half a million customers. Indeed, the opportunities our engineering team at Flywheel enjoy today stands on the shoulders of that giant.</p><p>Notwithstanding, a problem with all monoliths is that they have a tendency to continue to grow over time. And that’s exactly what happened at Flywheel during the prior five year period.</p><p>Just over two years ago we started thinking about embracing microservices. The catalyst for this was our CTO Mike Burlando who was recruited from a major fitness company where they built microservices. At his prior company, Mike had lots of resources to draw upon. However, when he joined Flywheel the development team consisted of only a few web developers and most of Flywheel’s systems were built by external contractors.</p><p>Mike had his work cut out for himself. Within a month of his arrival at Flywheel, he started recruiting engineers. Mike and I worked together in a prior effort and he convinced me to join his team at Flywheel. While I wasn’t initially pursued, I recognized that Flywheel’s use of IoT (before the term became mainstream) was particularly intriguing and even then there were internal aspirations of building a nation-wide live video streaming service.</p><p>During the first two months of my time at Flywheel, it was all hands on deck in support of our then new rebranding efforts. That meant that every engineer was focused on building a new ReactJS based site with a NodeJS backend. The complexity of that effort lied in the fact that our website was actually a web application which allows customers to book classes and view their historical stats. Due to time constraints, our efforts at the time relied heavily on the pre-existing monolithic backend API layer.</p><p>After the successful relaunch of the company site, Mike and I discussed building microservices in an effort to chisel away at the existing monolith. We understood that the microservices architecture embraces both focused modularity and distributed computing in an effort to build a collection of loosely coupled systems. That was particularly appealing because subsystems could be delegated to individual developers and external teams.</p><p>An emerging key driver was that we were preparing to build our FlyAnywhere platform which would allow our customers to ride at-home using our newly designed at home bike and our yet to be built, nation-wide live video streaming service. We were clear that such a service would require the agility that well-built microservices could offer.</p><h4>Initial challenges</h4><p>So we decided to embrace Microservices, after all, how hard could it be?</p><p>If you’re like the rest of us — some of these terms are still on your checklist. Now, it’s true that you don’t need to know all this to build microservices. But they are important tools and concepts, so navigating these concepts can help prevent complete loss time due to rework such as rewrites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*u_OfpWpJajjsniEIGuQyQQ.png" /></figure><p>So, clearly there was a lot to consider, and unfortunately, we were also a small team with limited resources. That’s three strikes if you’re counting! With microservices, there’s a lot more to consider, such as how services will work together, be monitored, DEBUGGED! and how their data sources will be organized.</p><p>Experts will tell you that small teams should not embrace microservices. One reason is that the microservices approach adds to the busy workload that developers already have. That was certainly the case at Flywheel where we had an extensive backlog of IT related projects across every department.</p><p>A core challenge was that there’s much to learn — which amounts to a lot of study time for an already busy team. Also, given that Flywheel is a business and not an R&amp;D group, we were naturally expected to deliver business features which didn’t necessarily include embracing microservices.</p><p>Still, we were clear that embracing microservices was the right thing to do in the short term and that the merits would have long-standing benefits.</p><p>One of the many challenges we faced was that we were too small a team to have our few developers running off in different directions — each implementing their version of a microservice. So we were leaning heavily on the use of a framework that would allow the team to build similar microservices while avoiding constructing the same general boilerplate code to address common concerns.</p><p>Our team at the time had varying degrees of Node and ExpressJS experience and so we wanted to keep close to that base while extending those skills with microservice features.</p><p>We were also growing as a team and we initially felt it would be faster to find ExpressJS developers than to find some with HapiJS, Koa or KrackenJS experience. In hindsight that probably wasn’t really a big deal.</p><h4>Over-engineering and importance of right-sizing</h4><p>As seasoned developers, we understood that a common pitfall that befalls teams of all sizes involves biting off more than they can chew. Whereby, over-committing and under delivering.</p><p>So a reality check was in order. We realized that we’re not Netflix, and as you read this, chances are you’re not either. Sure, if you <strong>are</strong> Netflix or any number of extremely large companies then you do need large scale solutions with fleets of supporting staff. We were clear that it was better to ship products than to spends months preparing to do so — by learning to use technology that exceeded our needs.</p><p>We were also keenly aware of the great tools that larger companies have contributed to open source. However, even those gifts from the gods come with steep learning curves.</p><p>Given our size, development budget and real business priorities we needed to “right size” a solution. We needed something small and robust enough to quickly get us started while affording us a runway whereby we could later embrace other solutions — as needed.</p><p>One of our most important goals was that an ideal framework had to be simple to use by less experienced developers. Ideally, a module implemented as a single package import. Our initial goal was to augment our Node and ExpressJS experience with tools that would allow us to build true microservices. I’d like to place emphasis on the phrase <em>true microservices</em>. To paraphrase Yoda (not that I’m not a fan of Starwars — as I don’t like fuzzy creatures in my SciFi — Star Trek Trebles notwithstanding…)</p><blockquote>A simple ExpressJS app does not a microservice make.</blockquote><p>We knew enough to know that building Node services with isolated concerns and matching RESTFul APIs falls short of what one could achieve with microservices. Granted, that probably would have in itself been a great start.</p><h4>But where to begin?</h4><p>In his book, The 7 habits of highly successful people, self-help author Steven Covey, wrote in habit number two: “Begin with the end in mind”. That is — begin by understanding the outcome you’re after. Then work towards that outcome.</p><p>So, we started by assembling a checklist of features we felt our microservices needed.</p><p>* Presence<br>* Service discovery<br>* Messaging<br>* Queuing<br>* Load balancing<br>* Routing<br>* Health<br>* Logging<br>* Configuration Management</p><p>If you already work with Microservices then this checklist is quite familiar.</p><p>At the time we started by investigating existing NodeJS modules for building microservices via NPM. In particular, we looked at SenecaJS— a mature toolkit for building microservices. There was a lot to like about Seneca. Its <em>message first</em> paradigm is spot-on for distributed computing. Couple that with its message pattern matching facility and you have an extremely powerful starting point. The one thing that didn’t resonate was that a SenecaJS-based microservice is markedly different from an ExpressJS app. The toolkit requires that developers embrace an entirely different mindset.</p><p><a href="https://feathersjs.com/">FeathersJS</a> is another mature framework we considered. With FeathersJS, the mindset required is a closer match for developers with ExpressJS experience. Still, we didn’t feel that it was entirely what we had in mind.</p><p>One of our most important goals was that an ideal package had to be simple to use by less experienced developers. The reason was that we wanted to keep our expenditures in check by limiting the need to hire extremely senior engineers.</p><p>In the packages that I investigated, it seemed that each varied in their support for microservice features and relied on external infrastructure dependencies.</p><p>So I’ve been working with Redis for some time, and along the way, as I considered our checklist, I decided to take a closer look at Redis. Most of us were exposed to Redis as a cache earlier in our careers. We like to say that we came for the cache and stayed for the data structures.</p><p>Along the way, I started seeing Redis as a sort of distributed computing glue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/153/1*cT9WU5dHimVwasqnoXDi2g.png" /><figcaption>Redis as Distributed Computing Glue</figcaption></figure><p>It looked like Redis could to be used to bind and unify microservices.</p><p>* Each microservice binds to a shared Redis cluster<br>* Presence is maintained by key/expiration<br>* Inter-process communication via Pub / Sub<br>* Routes placed in set stores</p><p>But was it possible? Microservice features using a single infrastructure dependency?</p><h4>Creating Hydra</h4><p>We thought so! So we set out to build an internal library called Hydra.</p><blockquote>The name Hydra seemed ideal because a service type often has multiple instances working together as a larger beast.</blockquote><p>We felt that if Hydra could address our feature checklist then it would be a good starting point for our efforts. Again, fully realizing that we were free to swap out functionality in favor of other technologies should the need arise.</p><h4>How about Docker, Kubernetes, and Nginx?</h4><p>Now, we’re routinely asked why we built Hydra instead of just using Docker or Kubernetes or even go retro with Nginx?</p><p>After all — aren’t we just duplicating existing functionality? It’s true that some of what Hydra offers is already present in Docker — but what’s nice about Hydra is that it works WITH or WITHOUT Docker, Kubernetes or Nginx.</p><p>It’s not an either-or proposition — but rather a matter of what you’re trying to achieve and how quickly you can get started. This was an important benefit for us as we were busy building products while learning about other technologies.</p><p>Today, we use Docker Swarm clusters on AWS in production without modifying Hydra.</p><h4>Powering FlyAnywhere</h4><p>So Hydra, with its single module import and a fairly simple class methods, allowed us to chisel away at our monoliths and start building our FlyAnywhere platform as a collection of microservices powered by Redis.</p><h4>Open Sourcing Hydra</h4><p>Fast forward nine months. FlyAnywhere was already well underway and Hydra was working really well for us. And we felt it would be useful to others. So, on November 7th, 2016 at the Smithsonian Museum of the American Indian in downtown Manhattan we open sourced Hydra on stage at the Empire Node conference.</p><p>I demo’ed Hydra running in a cluster of Raspberry Pi’s. My point in building the cluster was to reinforce the notion of a light-weight microservice library. In fact, light enough to run on $5 dollar Pi Zeros.</p><p>Here’s a close-up view of the cluster. It consists of eight computers. Seven of which are Raspberry Pi’s and one of which is an Arduino-based microcontroller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*Gfenl-NqU-3EC9Qu1o07lw.png" /></figure><p>Each of the Pi’s were running Hydra-enabled microservices using Node 6.5. In total, the cluster contained 16 CPU cores.</p><p>Since its open source debut, Hydra has been embraced by both smaller and larger companies than Flywheel Sports. A small but growing community has emerged and open source contributions are helping to further improve Hydra.</p><p>Is Hydra right for your organization? One way to check is to try it on a prototype or proof of concept project.</p><p>We suspect it’s particularly well suited for startups which have the freedom to choose their tools and who are rightfully concerned about quickly proving the market viability of their ideas. Flywheel Sports is far from a startup and we’re delighted in how well it’s served us. That said, we wouldn’t recommend Hydra for use by massive companies as their scale exceeds the practicality of using Hydra. For everyone else, Hydra may just be the sane way to build microservices.</p><h4>Using other programming languages</h4><p>We’ve built <a href="https://www.npmjs.com/package/hydra">Hydra as an NPM package</a> for NodeJS users. However, there’s nothing preventing anyone from doing the same with other languages. And because Hydra is open sourced it can serve as a reference platform for such efforts.</p><p>Along those lines, we’re pleased to announce that we have a Hydra-inspired Golang version in development, which we hope to open source soon. We’re also considering a Java-based version.</p><p>If you’re interested in building a Hydra package for your preferred platform, please feel free to reach out — we’d love to help!</p><h4>Launching FlyAnywhere</h4><p>So that’s why we built Hydra, and how we were able to both build and launch our FlyAnywhere platform, which is delighting our customers, nationwide!</p><p>Here is a photo of our Bluetooth-enabled at-home bike and metrics display.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*assuNMyLtZoQrK_m7__-kg.png" /></figure><p>A key callout here is that our microservices are dealing with real-time communication. Our Bikes emit real-time data which devices package into messages for transport via web sockets.</p><p>We broadcast live from our production studio in New York City. Our studio utilizes state-of-the-art broadcasting equipment similar to what you’d find in a News station. However, perhaps, unlike other studios, ours run a collection of microservices which support the automation of each live broadcast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CjnsMYobxZu5b6nVZ-nZQA.png" /></figure><p>So microservices power our production studio and serve customers via our AWS infrastructure. And we do all this using light-weight NodeJS microservices powered by Redis.</p><p>To learn more about Hydra visit <a href="https://www.npmjs.com/package/hydra">NPM.org</a>.</p><p><em>In the next part of this series, </em><a href="https://medium.com/flywheel-tech/building-light-weight-microservices-using-redis-23f051624647"><em>we explore exactly how Hydra leverages Redis</em></a><em> to build light-weight microservices.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11750470ba31" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flywheel-tech/embracing-microservices-11750470ba31">Embracing Microservices</a> was originally published in <a href="https://medium.com/flywheel-tech">FLY Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Road to Anywhere]]></title>
            <link>https://medium.com/flywheel-tech/the-road-to-anywhere-9039af05824d?source=rss----217bf8e263bb---4</link>
            <guid isPermaLink="false">https://medium.com/p/9039af05824d</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[product]]></category>
            <category><![CDATA[fitness]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Michael Burlando]]></dc:creator>
            <pubDate>Wed, 23 May 2018 17:42:32 GMT</pubDate>
            <atom:updated>2018-06-05T13:36:48.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o6dbmAz1FwxakQYcQ0Oywg.jpeg" /><figcaption>With FlyAnywhere and your own iOS or Android device, you can cast the class to your TV via AirPlay or Chromecast.</figcaption></figure><p><em>First in a multi-part series.</em></p><p>On November 15th, 2017, Flywheel launched <a href="https://shop.flywheelsports.com/">FlyAnywhere</a>, our home consumer bike and streaming content platform. We’ve been live now for months, the reviews are in (<a href="https://www.popsugar.com/fitness/Fly-Anywhere-Review-44499239">here</a> and <a href="https://laurenkaysims.com/2018/04/fly-anywhere-review-flywheel-at-home/">here</a>), and we just expanded our offering to the Android platform as well as launched a financing option for new customers. As CTO, working with such a talented and driven team has been the most rewarding experience of my career.</p><p>I joined the team (or “FlyFam” as affectionally named by our community of employees and guests) in the summer of 2015. After opening 40+ studios nationwide, we wanted to bring Flywheel’s signature studio experience to a new location- the home. The mission was clear: our offering would have all the elements that make Flywheel unique and authentic (from the torqboard to the high octane races and everything in between).</p><p>But the mission was also daunting. Delivering a home consumer product required systems and infrastructure that did not exist. From streaming high definition content to 3PL integrations to sourcing touch-screen consoles, the project demanded additional skills and developer horsepower.</p><p>We were outside the comfort zone from the start.</p><p>Yet … here we are.</p><p>This is the story of how we made it happen. In this series, team members of Flywheel Tech will describe some of toughest technical, product, and design challenges as well as our greatest moments of innovation. As with any complex project, the path to success is never linear and constant. It is fraught with gotchas and pitfalls that forced us back to the white board.</p><p>Throughout this series, you will notice a common theme among the team beyond the technical problem solving. Their unwavering grit and passion shown on a daily basis, in the end, was more critical to success than any individual’s genius or creativity. Our CEO Sarah Robb O’Hagan coined this as <a href="https://www.linkedin.com/pulse/when-you-ignite-your-magic-drive-can-fly-anywhere-sarah-robb-o-hagan">“Magic Drive”</a>.</p><p>This, most of all, is a story of resiliency.</p><p>This is the road to Anywhere.</p><p>— Mike</p><p><em>In the next part of this series, Chief Software Architect Carlos Justiniano </em><a href="https://medium.com/flywheel-tech/embracing-microservices-11750470ba31"><em>discusses how we leveraged a microservice philosophy</em></a><em> (and library) to divide and conquer among our small team.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9039af05824d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flywheel-tech/the-road-to-anywhere-9039af05824d">The Road to Anywhere</a> was originally published in <a href="https://medium.com/flywheel-tech">FLY Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>