<?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 Kekayan on Medium]]></title>
        <description><![CDATA[Stories by Kekayan on Medium]]></description>
        <link>https://medium.com/@kekayan?source=rss-4e57f49ef8f3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rFlVnmEeJ3fhEqvtl0ny0Q.jpeg</url>
            <title>Stories by Kekayan on Medium</title>
            <link>https://medium.com/@kekayan?source=rss-4e57f49ef8f3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:49:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kekayan/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[Forecasting with DeepAR: for busy people]]></title>
            <link>https://kekayan.medium.com/forecasting-with-deepar-for-busy-people-ed67f9d9a00d?source=rss-4e57f49ef8f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed67f9d9a00d</guid>
            <category><![CDATA[forecasting]]></category>
            <category><![CDATA[ar-deep]]></category>
            <category><![CDATA[lstm]]></category>
            <category><![CDATA[timeseries]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Kekayan]]></dc:creator>
            <pubDate>Mon, 11 Oct 2021 13:51:49 GMT</pubDate>
            <atom:updated>2021-10-11T14:45:26.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*it7N725lcuXh_pes" /><figcaption>Photo by <a href="https://unsplash.com/@m_malkovich?utm_source=medium&amp;utm_medium=referral">petr sidorov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this blog, I will explore time series forecasting using the DeepAR model developed by researchers at Amazon. This will be a code first guide to train time-series data to forecast.</p><p>DeepAR forecasting algorithm is a supervised learning algorithm for forecasting time series using recurrent neural networks (RNN).DeepAR can be trained on one or more related time series to predict future horizons given the preceding context. Since It’s a probabilistic model It will predict single best values for time index, the model parametrizes a parametric probability distribution for each time index. In this blog, We will use the <a href="https://ts.gluon.ai/">GluonTS</a> library’s DeepAR implementation.</p><h3>Setup</h3><p>In addition to pandas , numpy we need mxnet and gluonts. Let’s install those first by executing the pip command.</p><ul><li>If you are using CPU</li></ul><pre>pip install mxnet gluonts ujson</pre><ul><li>If you have GPU access then Install the GPU version of the mxnet.</li></ul><pre>pip install mxnet-cu101 gluonts ujson # GPU</pre><h3>Prepare the Dataset</h3><p>We will start with downloading our data on <a href="https://www.kaggle.com/andreazzini/international-airline-passengers">International airline passengers</a> from Kaggle.</p><p>Let’s import our data and prepare for training</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00001-614c95f7-e257-4d86-87f5-c6bec95bcacf%3Fheight%3D152&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00001-614c95f7-e257-4d86-87f5-c6bec95bcacf%3Fheight%3D152&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="152" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c49815c4b44d2a7ddba1181b0835795/href">https://medium.com/media/4c49815c4b44d2a7ddba1181b0835795/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00002-d59c2044-309d-41ae-8200-0dbe755e0ad4%3Fheight%3D116&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00002-d59c2044-309d-41ae-8200-0dbe755e0ad4%3Fheight%3D116&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="116" frameborder="0" scrolling="no"><a href="https://medium.com/media/11e687ba7ea06975003e9bb34f9e336f/href">https://medium.com/media/11e687ba7ea06975003e9bb34f9e336f/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00002-cba787e7-3979-47c2-8426-8424f8927aa1%3Fheight%3D341.20001220703125&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00002-cba787e7-3979-47c2-8426-8424f8927aa1%3Fheight%3D341.20001220703125&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="341" frameborder="0" scrolling="no"><a href="https://medium.com/media/5286a28bf72893f8b892e75d97c3bb56/href">https://medium.com/media/5286a28bf72893f8b892e75d97c3bb56/href</a></iframe><p>The data is about International airline passenger’s monthly counts in thousands starts from 1949 and ends in 1960. Since the last row has some noisy data, I will remove it and set the time stamp as the index.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00007-48a1f5c3-22fb-4b65-a9bd-61d4e566add2%3Fheight%3D483.20001220703125&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00007-48a1f5c3-22fb-4b65-a9bd-61d4e566add2%3Fheight%3D483.20001220703125&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="483" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b0ef918cd9b9bc19321753776aeb22c/href">https://medium.com/media/3b0ef918cd9b9bc19321753776aeb22c/href</a></iframe><p>Now let’s visualize our data over time.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00003-10be979f-e9ff-489e-ae8f-11b185d2c5e8%3Fheight%3D428&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00003-10be979f-e9ff-489e-ae8f-11b185d2c5e8%3Fheight%3D428&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="428" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cd7f467faefd23815e905e6edc9b212/href">https://medium.com/media/2cd7f467faefd23815e905e6edc9b212/href</a></iframe><p>Before passing the data to the model, We have to format our data which our library understands, Let’s do that now for training and test data. We need to create a ListDataset object. It should have at least a target variable, a start timestamp, and a frequency (min, H, M).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00008-46c76803-2fcb-4dd6-b88d-0590952a3d9e%3Fheight%3D116&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00008-46c76803-2fcb-4dd6-b88d-0590952a3d9e%3Fheight%3D116&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="116" frameborder="0" scrolling="no"><a href="https://medium.com/media/e559019c6a84a1427c80e3e7f5b8849a/href">https://medium.com/media/e559019c6a84a1427c80e3e7f5b8849a/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00009-3c0e2a19-b0f2-4822-8597-337d08f3fbe1%3Fheight%3D188&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00009-3c0e2a19-b0f2-4822-8597-337d08f3fbe1%3Fheight%3D188&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="188" frameborder="0" scrolling="no"><a href="https://medium.com/media/d801e2b144437ee26d343703fe7efd5c/href">https://medium.com/media/d801e2b144437ee26d343703fe7efd5c/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00010-d8605a09-4560-4acb-a2ab-9db552012e2e%3Fheight%3D471&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00010-d8605a09-4560-4acb-a2ab-9db552012e2e%3Fheight%3D471&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="471" frameborder="0" scrolling="no"><a href="https://medium.com/media/14e963d1a75b2d5da5c51ba949e0f323/href">https://medium.com/media/14e963d1a75b2d5da5c51ba949e0f323/href</a></iframe><p>The training data needs to contain the train data only, But the test data needs to contain both train and test data.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00014-99f4ee7f-52cc-48d7-a650-f5ddb1e5c2ba%3Fheight%3D170&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00014-99f4ee7f-52cc-48d7-a650-f5ddb1e5c2ba%3Fheight%3D170&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="170" frameborder="0" scrolling="no"><a href="https://medium.com/media/afd96fdbbf9321677be4ad948eccbf0a/href">https://medium.com/media/afd96fdbbf9321677be4ad948eccbf0a/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00016-753e8e66-3854-41da-9502-67f2ae9ae597%3Fheight%3D489&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00016-753e8e66-3854-41da-9502-67f2ae9ae597%3Fheight%3D489&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="489" frameborder="0" scrolling="no"><a href="https://medium.com/media/897aea9aec0a7146ac45ffee28f9e87b/href">https://medium.com/media/897aea9aec0a7146ac45ffee28f9e87b/href</a></iframe><p><strong>Model</strong></p><p>Now we will create our DeepAR model instance by creating an object of DeepAREstimater . GluonTs uses Estimators to encapsulate model and predictor in other words Estimators represents a model that can be trained to yield predictor after training.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00009-1b8a07ed-eceb-4bb0-b2cf-b74cc5760e10%3Fheight%3D209&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00009-1b8a07ed-eceb-4bb0-b2cf-b74cc5760e10%3Fheight%3D209&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="209" frameborder="0" scrolling="no"><a href="https://medium.com/media/af6a7fe92b7e8a3af2ab130f88ded2eb/href">https://medium.com/media/af6a7fe92b7e8a3af2ab130f88ded2eb/href</a></iframe><p>Let’s Intializise our DeepAR model with a few hyperparameters and callbacks for Learning Rate Scheduling &amp; model Averaging.</p><p>Few important parameters,</p><ul><li>context_length — The number of time-points that the model gets to see before making the prediction.</li><li>prediction_length — The number of time-steps that the model is trained to predict, also called the forecast horizon.</li><li>freq — The granularity of the time series in the dataset.</li><li>num_cells — The number of cells to use in each hidden layer of the RNN.</li><li>num_layers — The number of hidden layers in the RNN.</li></ul><p>You can check the full list of hyperparameters <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/deepar_hyperparameters.html">here</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00012-fd5e5a26-90b3-435a-a825-daa80c82be11%3Fheight%3D479&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00012-fd5e5a26-90b3-435a-a825-daa80c82be11%3Fheight%3D479&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="479" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8a80cb0f2c91a247623c7eb30398f27/href">https://medium.com/media/c8a80cb0f2c91a247623c7eb30398f27/href</a></iframe><h3><strong>Evaluate</strong></h3><p>Now we can use the predictor to forecast our test data.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00014-7b8bc5e3-0a24-46d8-ae70-54c7a64052d2%3Fheight%3D443&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00014-7b8bc5e3-0a24-46d8-ae70-54c7a64052d2%3Fheight%3D443&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="443" frameborder="0" scrolling="no"><a href="https://medium.com/media/262e8653fdbb3c30f299199780eeb6cb/href">https://medium.com/media/262e8653fdbb3c30f299199780eeb6cb/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00016-d675aa84-92cd-4ac9-b04a-f61c6664bc72%3Fheight%3D83&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00016-d675aa84-92cd-4ac9-b04a-f61c6664bc72%3Fheight%3D83&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="83" frameborder="0" scrolling="no"><a href="https://medium.com/media/71d22ad31fce78b4f69c1c25e4efa235/href">https://medium.com/media/71d22ad31fce78b4f69c1c25e4efa235/href</a></iframe><p>You will see the probabilistic forecast from the following graphs. The model provides an estimate of how confident the model is, and allows downstream decisions based on these forecasts to account for this uncertainty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*iqCngWOgxtigaarkCjz7EA.png" /></figure><p>Let’s check metrics such as MSE, MASE, symmetric MAPE, RMSE using Evaluator from gluonTs.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00019-271a1a68-61ca-4902-b485-ef44b3887e79%3Fheight%3D790&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F66d2eb6a-ea56-4568-b65d-f61fcc0dc465%2F232d50f3-7bd8-49c2-9635-1caf7faeeb9c%2F00019-271a1a68-61ca-4902-b485-ef44b3887e79%3Fheight%3D790&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="790" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b6dbc7ae0165c95e24aa6231c8284e9/href">https://medium.com/media/9b6dbc7ae0165c95e24aa6231c8284e9/href</a></iframe><p>happy forecasting :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed67f9d9a00d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Latest trends in User Interfaces]]></title>
            <link>https://medium.com/swlh/latest-trends-in-user-interfaces-341d9d64f4f7?source=rss-4e57f49ef8f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/341d9d64f4f7</guid>
            <dc:creator><![CDATA[Kekayan]]></dc:creator>
            <pubDate>Fri, 29 Nov 2019 15:08:09 GMT</pubDate>
            <atom:updated>2019-12-08T12:59:11.004Z</atom:updated>
            <content:encoded><![CDATA[<p>When I say User Interfaces, I think you are expecting me to talk about web interfaces or mobile interfaces. But truth is, user interfaces is a broader concept than that.</p><blockquote>User Interfaces are mechanisms that humans can effectively interact with machines.</blockquote><p>Most common ones we see is a mouse click or keyboard input. But the time of mouse and keyboard will be long gone by the next decade. So we will today talk about the emerging new technologies of user interfaces such as,</p><ul><li>Motion Sense</li><li>Voice User Interfaces</li><li>Virtual Reality</li><li>Augmented Reality</li><li>Mixed Reality</li></ul><p>So are you interested? (You should be!) This whole discussion will sound like straight out of the movie Iron Man :P</p><h3><strong>Motion Sense</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKnRbXWojW7c%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKnRbXWojW7c&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKnRbXWojW7c%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9dae7e0442d697153c007f777272f083/href">https://medium.com/media/9dae7e0442d697153c007f777272f083/href</a></iframe><p>One of the most recent talks or trends in UI &amp; UX world is the gesture-based input. With the launch of new Google Pixel 4, which has a tiny radar chip inside it, gesture interfaces become the talk of the time. Google Pixel 4 allows you to swipe or wave your hand in front of it, to get many things done. Nevertheless, most importantly, Motion Sense is designed to detect your presence. It knows if you’re there.</p><blockquote>Of course, is the same technology that has been used for decades to detect planes and other large objects. We’ve developed a miniature version located at the top of Pixel 4 that senses small motions around the phone, combining unique software algorithms with the advanced hardware sensor, so it can recognize gestures and detect when you’re nearby. — Google</blockquote><p>Motion Sense features to allow you to skip songs, snooze alarms, and silence phone calls, just by waving your hand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/0*x1gBy5iLZbzLItN-.png" /><figcaption>The radar chip on a pixel device</figcaption></figure><p>Motion Sense has essentially <em>three types</em> of interactions, according to Brandon Barbello, Pixel product manager at Google such as,</p><p><strong>Presence - </strong>The Project Soli radar chip inside the Pixel 4 creates a small bubble of awareness around the phone when it’s sitting on a table. It just keeps an eye out to ensure we’re nearby and turns off the always-on display if you’re not.</p><p><strong>Reach - </strong>The phone just pays attention to see if We’re reaching for it and then quickly turns on the screen and activates the face unlock sensors. If an alarm or ringtone is going, the phone automatically quiets down a bit when it seems we’re reaching for it.</p><p><strong>Gestures - </strong>This is were actual gestures are coming. There are more things we can do. For example, We can give it a quick wave to dismiss those calls or snooze alarms. We can also swipe left or right if music is playing to go forward or back.</p><p>Google is limiting what Motion Sense can do because it is creating an entirely new interaction language, and it needs to limit the vocabulary at the beginning. Otherwise, it would be overwhelming — or at least super annoying.</p><p>Google even learned that we don’t actually have a common language for what “swipe left” and “swipe right” mean. Different people move their hands in different directions depending on their mental model of whether the direction refers to their hand or the thing they’re virtually interacting with. Google ended up having to put a preference setting in for those who wanted to flip the defaults.</p><p>If you talk about usability provided by this new chip can be simply answered by asking one question</p><blockquote>Do i need my phone to wake up a half-second before I touch it, saving me a tap on the screen.?</blockquote><p>Clearly people want to remove a small amount of friction when they move forward with technology. So It’s a clear winner.</p><p>And besides, you can always use your phone with dirty or wet hands, because you are not going to touch the phone physically.</p><p>Even though I took the Google Pixel 4 as the best example. There are also many other motion-based systems for various different use cases like smart homes, automatic photo taking etc. Many other use cases are being explored by the research which is carried out all over the world.</p><h3><strong>AI integrated VOICE User Interfaces</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFQn6aFQwBQU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFQn6aFQwBQU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFQn6aFQwBQU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a44354049784721cb8a69f8067ea81a/href">https://medium.com/media/1a44354049784721cb8a69f8067ea81a/href</a></iframe><p>In the years to come, AI technology will continue towards perfection. This should lead to a smooth and consistent interaction, Surveys saying voice will perform an expected 50% of all search engine queries.</p><p>Chatbots and communicating interfaces have also trending now. Machine learning has improved, making chatbots smarter. Now, many websites and apps have started using voice communication for enhanced user experience. This includes Google’s autosuggestion, smart home voice user interfaces like Google Home or Amazon’s Alexa, virtual assistants such as Apple’s Siri, and Microsoft’s Cortona.</p><p>Researches include speech to text, text to speech, QnA and some researches on knowledge graph and more NLP stuff. Many Research papers for the domain can be accessed <a href="https://developer.amazon.com/en-US/alexa/science">here</a>.</p><p>Looking at the usability aspects, voice interfaces are way easier to use than gesture or other interfaces. (Traditional interfaces can’t even come to compete). You will be wondering why is that. The reason is, voice or the talking is the most prefered human interaction methodology. We can do it even without paying much attention to it, while doing other work. Also unlike most of the Extended Reality applications, you don’t need wearable devices for this.</p><p>Now moving on to the next topic, let&#39;s talk about an Extended Reality variation, Virtual Reality.</p><h3>Virtual Reality</h3><p>Virtual reality plays a strong role in UI trends and it’s not going away. We could call it the internet of experiences because of the effect that it has on users.</p><p>Recently New Virtual Reality Interface Enables “Touch” Across Long Distances. The Lightweight, flexible patch conveys a tactile sensation directly to the skin</p><p>Research says</p><blockquote>A woman sits at a computer, video chatting with her young son while she gently pats an interface on a separate screen. In response, a wireless patch on the child’s back vibrates in a pattern that matches his mother’s fingers, allowing him to “feel” her physical touch.</blockquote><p>The skin machine consists of a soft, lightweight sheet of electronics that sticks to the body. It uses a combination of pressure, vibration and motion to simulate the sense of touch for users.</p><p>Another trend VR mostly famous for is Gaming. It enhances much experience.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKXFJoot3bts%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKXFJoot3bts&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKXFJoot3bts%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fbbe833135ee29f2671101ea0ba6790/href">https://medium.com/media/6fbbe833135ee29f2671101ea0ba6790/href</a></iframe><p>There are many more applications of VR in different sorts of domains like education, medicine, military, gaming, etc. and various researches were carried out with respect to those domains.</p><p>Talking about the usability aspect, there are pluses and minuses both for these interfaces. Plus points include the immersive experience they provide, high discoverability (Sometimes it may depend on the complexity of the application.), and active feedback. On the minus side, we need to use appropriate gadgets and we need to concentrate on it fully unlike voice interfaces. (Maybe in future these may change). Another major point to notice is the motion sickness aspect of VR usability. Developers should be extra careful to stick to standards while developing VR applications because of this reason.</p><p>Let’s move on to another aspect of Extended Reality, that is Augmented Reality.</p><h3>Augmented Reality</h3><p>Designers will need to go beyond screen-only interfaces to include physical interactions. Augmented Reality has ushered in a new era in user interface design, a new way of thinking.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FsB7fx7v62oo%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DsB7fx7v62oo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FsB7fx7v62oo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdc34f64bc89cb3362b51e51ac02bdb7/href">https://medium.com/media/cdc34f64bc89cb3362b51e51ac02bdb7/href</a></iframe><p>In 2019, web design trends will all involve thinking outside the box, or rather, the grid. We need to forget UI fixed to screens. Instead, we should emphasize interactions which feel like they take place within the real-world environment.</p><p>Google and Apple have already introduced their own AR development platforms, ARCore and AEKit, that blend the physical and digital worlds.</p><p>AR UI can have different approaches:</p><ul><li>Object-related, real-world objects that have tethered interaction;</li><li>Fixed to screen space, where the user has to position the camera in a specific way;</li><li>Real-world related, which uses the surrounding physical world.</li></ul><p>Therefore, we must carefully think through the context and function of AR experience.</p><p>Some of the famous implementations of Augmented Reality includes, Pokémon Game, FaceApp, Instagram/Facebook/SnapChat filters, etc. The researches are carried out to exploit possibilities of AR applications in all main domains like education, medicine, military, etc. and those research are lead by USA, Japan, China and Europe.</p><p>Looking at the usability aspects, similar to the VR interfaces, AR also have the impressive capability to provide immersive applications. On the other hand, there is no motion sickness like VR.</p><p>Now let&#39;s move on to the final aspect of Extended Reality.</p><p><strong>MIXED Reality</strong></p><p>A mixed-reality environment goes a step beyond augmented reality because users can interact in real-time with virtual objects that are placed within the real world. These virtual items will respond and react to users as if they were actual objects.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2MqGrF6JaOM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2MqGrF6JaOM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2MqGrF6JaOM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a555b6e45f6cc491bf14890e6f6bcfe8/href">https://medium.com/media/a555b6e45f6cc491bf14890e6f6bcfe8/href</a></iframe><p>In order to experience mixed reality, an MR headset is used. MR headsets offer a holographic experience through translucent glasses or an immersive experience. Some mixed reality products that are currently available include Microsoft’s<a href="https://www.microsoft.com/en-us/hololens"> HoloLens</a>, Acer Windows Mixed Reality, Lenovo Explorer, and Samsung Odyssey.</p><p>It’s the gesture/gaze/voice recognition technology through a pair of motion controllers or through the MR headset that helps deliver a believable mixed-reality experience. It takes a lot more processing power to enable a mixed-reality experience than it does for a virtual or augmented reality experience. But it’s experience is also a few steps ahead of the others.</p><p>In my opinion, Mixed reality is the real future of user interfaces. Why I said that is because it can exploit many human activities, like speaking, looking, gesture and some systems can even simulate touch. Maybe in future, they may be able to simulate smell as well.</p><p>If you are mixed up about different between VR, AR and MR, check out the bellow video:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3mr_S5mOtsw%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3mr_S5mOtsw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3mr_S5mOtsw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f723e024640fc0e1448ab94f70af6278/href">https://medium.com/media/f723e024640fc0e1448ab94f70af6278/href</a></iframe><p>So that’s it for today. I hope it is an interesting discussion. In the next decade, don’t be surprised if you see Iron Man’s J.A.R.V.I.S in one of the offices you step into, because that is where the technology is leading us into.</p><p>Leave a comment below, if you have new additions to this trend list! All criticisms and arguments are warmly welcome!</p><p>See you in another article! Chao!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=341d9d64f4f7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/latest-trends-in-user-interfaces-341d9d64f4f7">Latest trends in User Interfaces</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A step by step guide for deploying flask web services on GKE cluster]]></title>
            <link>https://kekayan.medium.com/a-step-by-step-guide-for-deploying-flask-web-services-on-gke-cluster-76420d75671d?source=rss-4e57f49ef8f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/76420d75671d</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[minikube]]></category>
            <category><![CDATA[gke]]></category>
            <dc:creator><![CDATA[Kekayan]]></dc:creator>
            <pubDate>Sat, 04 May 2019 13:50:50 GMT</pubDate>
            <atom:updated>2019-05-04T13:50:50.612Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome back with another step-by-step guide!</p><p>Today I am going to do a guide on one of the most widely used technologies in the tech world. That is Kubernetes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wzbtF8AsnEWfzbjCjSsUg.png" /></figure><p>Bellow is the outline of our today’s guide:</p><ul><li>What is Kubernetes</li><li>Story of Container Orchestrators</li><li>Scenario of the Hands-on</li><li>Developing Services &amp; Docker images</li><li>MiniKube: Local Kubernetes Deployment</li><li>Deploy in cluster</li></ul><h3>What is Kubernetes</h3><p>Kubernetes is a Google born technology for Container Orchestration. However, currently, it is functioning as an Open source service under the Apache 2.0 license.</p><p>Before going forward, let me describe the term “Container Orchestrator” bit more.</p><h3>Story of Container Orchestrators</h3><p>With the evolution of computers, people thought of scaling their applications in more efficient and effective ways. They come across mechanisms to rent their unused space of the data centres. This is where business bloomed for companies like Amazon or Google. The concepts like Virtual Machines helped people to use machines far away in unknown territories. But in a virtual machine, the main disadvantage will be the waste of resources on the operating system. So people came up with a solution for it. <strong><em>Containers</em></strong>.</p><p>Containers are very much similar to Virtual Machine, except, it does not need its own Operating system. This made the scaling of applications even more resource effective and efficient.</p><p>Within a very small time period, containers started to rule the IT industry. But the next problem was how to control and manage those numerous containers that one system own? What about companies with many systems and products? These containers needed upgrades, version controls, security patches, health checks and many more. People wanted to manage similar containers with the simplest possible way.</p><p>That is where the <strong><em>Container Orchestrators</em></strong> were born. An orchestrator tells the containers on what to do, where to be etc. It made the life of dev-ops easier. All the updates, roll-backs, patches are now one YAML away, literally.</p><p>So this is the story of a Container Orchestrator. Our Kubernetes is one such Orchestrator. I will explain more theories along-side our practical.</p><h3>The scenario of the Hands-on</h3><p>Think a scenario where we have two services data service &amp; API service where data service not exposed to public and API service exposed to the public. See the diagram below for understanding</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*krNneoOjRxMQRXQx9JmQYQ.jpeg" /></figure><p>1. API-service — expose 2 API endpoints as “/codeToState” and “/stateToCode” , pass parameters as URL parameters <br><a href="http://host/codeToState?code=XX">http://host/codeToState?code=XX</a><br><a href="http://host/stateToCode?state=XXXXXXX">http://host/stateToCode?state=XXXXXXX</a></p><p>2. Data-Service <br> read data from this <a href="https://gist.github.com/mshafrir/2646763#file-states_hash-json">JSON</a> or this <a href="https://gist.github.com/mshafrir/2646763#file-states_titlecase-json">JSON</a> and provide relevant data requested by APIService</p><p>First, start with services and make the docker container</p><h3>Developing Services &amp; Docker images</h3><p>before start developing our service we need to install packages and dependencies</p><p>First install python, pip (python package manager), git and docker. Finally, we use pip to install the virtual environment</p><pre>sudo apt-get update<br>sudo apt-get install python-dev python-pip git docker.io<br>sudo pip install virtualenv</pre><h4>1. Set up the project</h4><ul><li>Make a new empty directory for the project. data_service</li><li>Set up a virtual environment in a directory called <em>venv</em> with the command virtualenv venv</li><li>Activate the virtual environment with source venv/bin/activate</li><li>Make a file requirements.txt that has all your dependencies in it. For the simplest flask app we need only</li></ul><pre>Flask==1.0.2<br>requests</pre><ul><li>Install your dependencies with pip install -r requirements.txt</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n4T35mm5IPtwchb8iSNDnw.png" /><figcaption>setup project</figcaption></figure><h4>2. Code the endpoints</h4><ul><li>Make a flask app at app/main.py</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UN_ZSx3rCujhW4EWgQS8qQ.png" /><figcaption>setup flask project</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b615fdc6e3e32201724b6dda35c88837/href">https://medium.com/media/b615fdc6e3e32201724b6dda35c88837/href</a></iframe><ul><li>when we call ip/codes it will return codes: states json and ip/states other way.</li></ul><h4>3. Make the Dockerfile</h4><p>A Dockerfile is a file called Dockerfile (with no extension ) which tells Docker how to build an image.</p><p>I will use base docker image from <a href="https://github.com/tiangolo">Sebastián Ramírez</a> .which have nginx docker flask pre-installed.</p><p>Our directory Structure should be like this</p><pre>.<br>├── app<br>│   └── main.py<br>└── Dockerfile<br>└── requirements.txt</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdf605bbb2e554d169773a4596d9f2a0/href">https://medium.com/media/cdf605bbb2e554d169773a4596d9f2a0/href</a></iframe><h4>4. Explanation for docker file</h4><h4><strong>FROM</strong></h4><p>This line tells Docker what image to pull from the Docker hub repository (it’s like GitHub for Docker containers). The image specified by FROM is the base of the container we are building. It has python, flask, nginx, and uWSGI (the bridge between Flask and Nginx) as well as some other tools like git installed for us on a Debian OS.</p><p>You can think of a Docker image as a virtual operating system, but with smaller file size and with better efficiency. The tiangolo/uwsgi-nginx-flask:flask sets up a Debian Jesse “virtual operating system” which can run on our Ubuntu machine, or on pretty much any machine. The settings, installed programs, and even the operating system of our machine doesn’t matter – Docker makes its own isolated container.</p><h4><strong>COPY</strong></h4><p>This is how our app’s code gets incorporated into the Docker container. As you might expect, it copies the appdirectory from our project directory to the Docker container’s /app directory, overwriting the default app that Sebastián set up in there with our own.</p><h4><strong>5. Building Docker Image— </strong>docker build</h4><pre>docker build -t data_service .</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KSpk4f_i_T4q0cWtiFk1Mg.png" /></figure><p>This tells Docker to build a container using the project in the present working directory (the . at the end), and tag it data_service (-t stands for “tag”). Docker will pull down the base image tiangolo/uwsgi-nginx-flask:flask from Docker Hub, then copy our app code into the container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SqJgE4V-qGapM02OO4aVyg.png" /></figure><p>we can check docker image by</p><pre>docker images</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L6kxKphCZ_qGhLv5-C6smw.png" /></figure><h4>6. Run the Docker Image — docker run</h4><p>docker run -p 80:80 -t data_service</p><ul><li>-p connects port 80 of the Docker container to port 8080 of your machine, so HTTP can work.</li><li>-t again specifies the tag of the container we want to run.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jXKkXEJgFV490PCEyIGB-Q.png" /></figure><p>Check in the Localhost:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X5JRKgIEAq7sKZ9ReGoJMQ.png" /></figure><h4>7. API service and related Docker Container</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j5v5Hg1-fznMYQvMTnuX7Q.png" /></figure><p>Similarly to data_service:</p><ul><li>we create a directory called api_service</li><li>Create a virtualenv called <strong><em>venv</em></strong></li><li>Let’s create <em>requirements.txt</em> and add <em>flask &amp; requests</em></li><li>Activate the environment and install requirements</li><li>Then we create our python file <strong><em>app/main.py</em></strong></li><li>And we create our Dockerfile</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93fd9269e57bb8d35605f82f2bd7cce0/href">https://medium.com/media/93fd9269e57bb8d35605f82f2bd7cce0/href</a></iframe><p>Before Deploy everything in Google cloud let’s try to deploy in our local machine using MiniKube.</p><h3><strong>MiniKube: Local Kubernetes Deployment</strong></h3><h4>1. Prerequisites</h4><ul><li>Install Minikube &amp; setup (<a href="https://kubernetes.io/docs/tasks/tools/install-minikube/"><em>official guide here</em></a>)</li><li>Install Kubectl &amp; setup (<a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/">official guide here</a>)</li></ul><p>Let’s start Minikube first</p><pre>minikube start</pre><p>Now we ssh/ Login to Minikube VM and create docker images as we mentioned earlier.</p><pre>minikube ssh</pre><h4>2. Build Docker images</h4><ul><li>clone the repos <a href="https://github.com/kekayan/data_service_example">data_service</a> &amp; <a href="https://github.com/kekayan/api_service_example">api_service</a> ( i provided links)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bs0fTRNLcnda0Thjm7iPiQ.png" /></figure><ul><li>build the two docker images after cd to each directory</li></ul><pre>docker build -t api_service:v1a .<br>docker build -t data_service .</pre><p>we can see the docker images by running docker images</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8lxu3TRcHn5dbqgtkFAYiA.png" /></figure><p>exit from VM.</p><h4>3. Deploy in Minikube</h4><p>Now the time to deploy our two conatiners or dockers to Kubernetes .</p><p>we will use kubectl to deploy our pods and create services.</p><h4><strong><em>PODS</em></strong></h4><p>When we want to run an application in Kubernetes we do so by declaring a <strong>Pod</strong> which describes the container that we want to run. Each <strong>Pod</strong> is given an IP address that is internal to the Kubernetes cluster but this IP is not accessible from outside of Kubernetes. Even from inside Kubernetes you’d have to know the IP of the <strong>Pod</strong> to access it which is inconvenient at best.</p><p>we can create a simple <strong>Deployment</strong> to manage a <strong>Pod</strong> as below</p><pre>kubectl  run dataservice --image=data_service:latest --image-pull-policy=Never --port=80<br>kubectl  run apiservice --image=api_service:v1a --image-pull-policy=Never --port=80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ov7bPXQWipm40ZlGjXcwzw.png" /></figure><p>Let’s create service</p><h4><strong>Why use a Service?</strong></h4><p>In a Kubernetes cluster, each Pod has an internal IP address. But the Pods in a Deployment come and go, and their IP addresses change. So it doesn’t make sense to use Pod IP addresses directly. With a Service, we get a stable IP address that lasts for the life of the Service, even as the IP addresses of the member Pods change.</p><p><strong>Types of Services</strong></p><p>There are five types of Services:</p><ul><li><strong>ClusterIP (default):</strong> Internal clients send requests to a stable internal IP address.</li><li><strong>NodePort:</strong> Clients send requests to the IP address of a node on one or more nodePort values that are specified by the Service.</li><li><strong>LoadBalancer:</strong> Clients send requests to the IP address of a network load balancer.</li><li><strong>ExternalName:</strong> Internal clients use the DNS name of a Service as an alias for an external DNS name.</li><li><strong>Headless:</strong> You can use a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#headless-services">headless service</a> in situations where you want a Pod grouping, but don’t need a stable IP address.</li></ul><p>According to our architecture above here<em> </em><strong><em>both</em></strong> “<em>api_service”</em> and “<em>data_service</em>” are running on the <em>same</em> Kubernetes cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*krNneoOjRxMQRXQx9JmQYQ.jpeg" /></figure><ul><li>we have to define a Service for the app that we want to call (data_service) using type: ClusterIP type service since it doesn’t need to expose to public</li><li>Api_service with NodePort if we are using MiniKube or LoadBlancer in cloud.</li></ul><p>data_service is in a namespace named default, define a service named dataservice for the data_service deployment and then configure the api_service to call data_service at this URI:</p><pre>http://dataservice.default.svc.cluster.local/codes<br>http://dataservice.default.svc.cluster.local/states</pre><p>update above url in the api_service application.</p><p>To create service</p><pre>kubectl  expose deployment dataservice --type=ClusterIP<br>kubectl  expose deployment apiservice --type=NodePort</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NmPoPXROsQQHN6DvFy6RLw.png" /></figure><p>Now we can check the URL:</p><pre>echo $(minikube service apiservice --url)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZztSCLxqt0fNSLVndqW_w.png" /><figcaption>postman</figcaption></figure><p>So Now we tested each endpoint. You can see the results above.</p><h3>GKE Cluster Deployment</h3><p>Now, let’s Deploy the system in GKE Cluster</p><ul><li>Create your project <a href="https://console.cloud.google.com/cloud-resource-manager?_ga=2.57223722.-1043674917.1556810873">here</a></li><li>Now select cloud shell</li><li>we will clone our repos in there</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*79oJBLI6H5rDLa1XY-SQ0w.png" /></figure><h4>1. Build docker containers for both</h4><p>Set the PROJECT_ID environment variable in your shell by retrieving the pre- configured project ID on gcloud by running the command below:</p><pre>export PROJECT_ID=”$(gcloud config get-value project -q)”</pre><p>To build the container image of this application and tag it for uploading, run the following command:</p><pre>docker build -t gcr.io/${PROJECT_ID}/data_service:v1 .<br>docker build -t gcr.io/${PROJECT_ID}/api_service:v1 .</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*imv1fiP4GuzEmlbe0fmJqw.png" /></figure><h4>2. Upload the container image</h4><ul><li>First enable the <a href="https://cloud.google.com/container-registry">conatiner registry api</a>.</li><li>configure Docker command-line tool to authenticate to Container Registry (we need to run this only once):</li></ul><pre>gcloud auth configure-docker</pre><ul><li>we can now use the Docker command-line tool to upload the image to your Container Registry:</li></ul><pre>docker push gcr.io/${PROJECT_ID}/data_service:v1<br>docker push gcr.io/${PROJECT_ID}/api_service:v1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qqTlTkJmAiYyUFTuE2glRQ.png" /><figcaption>pushing api service to conatiner registry</figcaption></figure><h4>3. Create a container cluster</h4><p>A cluster consists of a pool of <a href="https://cloud.google.com/compute">Compute Engine VM instances</a> running <a href="https://kubernetes.io/">Kubernetes</a>, the open source cluster orchestration system that powers GKE.</p><ul><li>Enable the billling API for GKE</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dZA_4dcLYUrSAjOJJvpUpg.png" /></figure><ul><li>Let’s create a two-node cluster named mediumtuts-cluster</li></ul><pre>gcloud container clusters create mediumtuts-cluster --num-nodes=2 --zone=us-central1-b</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dekBNqfxMnIq4E5ULyLKcQ.png" /></figure><p>check our cluster</p><pre>gcloud compute instances list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lk7X8TDBlBWkvnkcGABfWw.png" /></figure><h4>4. Deploy our two services/apps</h4><pre>kubectl  run dataservice --image=gcr.io/${PROJECT_ID}/data_service:v1 --port 80</pre><pre>kubectl  run apiservice --image=gcr.io/${PROJECT_ID}/api_service:v1 --port 80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j7-f9A472brpYDnZ9rMp1g.png" /></figure><h4>5. Expose our API service to the Internet</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N0n2S-iNOtlZ9yhHl4HiNg.png" /></figure><pre>kubectl  expose deployment dataservice --type=ClusterIP<br>kubectl  expose deployment apiservice --type=LoadBalancer</pre><p>So after a few minutes if we run kubectl get svc</p><p>We can see the load balancer IP like the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KimMBktCxzqxfafRtYcybw.png" /></figure><p>So if we try our endpoints we can see the results</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xXSuFiGvxqsYUIcl3h5nA.png" /><figcaption>satetocode</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FUBnwYJA2ZfvNurCxshU0A.png" /><figcaption>codetostate</figcaption></figure><p>DashBoard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fCDFjdehBr02U_RlwhdEyA.png" /><figcaption>GKE Dashboard</figcaption></figure><ul><li>For scale up &amp; cleaning check the <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app">official guide</a></li></ul><p>I ll attach both services repo here</p><ul><li><a href="https://github.com/kekayan/api_service_example">kekayan/api_service_example</a></li><li><a href="https://github.com/kekayan/data_service_example">kekayan/data_service_example</a></li></ul><h3>References</h3><p>Czarkowski, P. (2019). <em>Kubernetes Services: Exposed!</em>. [online] Medium. Available at: <a href="https://medium.com/@pczarkowski/kubernetes-services-exposed-86d45c994521">https://medium.com/@pczarkowski/kubernetes-services-exposed-86d45c994521</a> [Accessed 4 May 2019].</p><p>Google Cloud. (2019). <em>Deploying a containerized web application | Kubernetes Engine Tutorials | Google Cloud</em>. [online] Available at: <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app">https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app</a> [Accessed 4 May 2019].</p><p>Google Cloud. (2019). <em>Service | Kubernetes Engine | Google Cloud</em>. [online] Available at: <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/service">https://cloud.google.com/kubernetes-engine/docs/concepts/service</a> [Accessed 4 May 2019].</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76420d75671d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to Kafka Clustering in Ubuntu 18.04]]></title>
            <link>https://kekayan.medium.com/a-guide-to-kafka-clustering-in-ubuntu-18-04-5eac0eaf08a2?source=rss-4e57f49ef8f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eac0eaf08a2</guid>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <dc:creator><![CDATA[Kekayan]]></dc:creator>
            <pubDate>Fri, 29 Mar 2019 17:56:44 GMT</pubDate>
            <atom:updated>2019-03-29T17:59:34.972Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome back with another guide. Let’s create a cluster and understand what is Apache Kafka. Kafka is a distributed publish-subscribe messaging application written by LinkedIn. Kafka is often compared to Apache ActiveMQ or RabbitMQ, but the fundamental difference is that Kafka does not implement JMS (Java Message Service).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/0*_8662jNXQzTOSgcF.png" /></figure><ol><li>What is Kafka</li><li>The architecture of the Kafka</li><li>Diving into Components ,Partition &amp; Replication</li><li>Features of Kafka</li><li>Setting up a Kafka server on Ubuntu</li><li>Setting Up a Kafka Cluster</li></ol><h4>What is Kafka?</h4><p>A Messaging System. That’s it? if so why people are excited. But Kafka is more than that, It’s a distributed streaming platform. It means we can use Kafka as</p><ul><li>a Messaging System</li><li>a Storage System</li><li>for Stream Processing</li></ul><p>You can read more on the official tutorial about it <a href="https://kafka.apache.org/intro.html">https://kafka.apache.org/intro.html</a>.Let’s check the quick overview and set up a small cluster in the local machine.</p><h4>The architecture of the Kafka</h4><p>we will start with some basics on how Kafka works, the basic terminologies, and the components.</p><p>Kafka is a messaging system. So we have messages. <strong><em>Messages are organized into topics</em></strong>. So when we need to send a message, we send it to a specific topic. When we want to read a message, we decide which topic we are going to read a message from. Producers push the messages. Consumers pull the messages. So <strong><em>Kafka is a consumer pull system.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R35KpdAB-bAdFx7s.png" /><figcaption>Kafka Architecture</figcaption></figure><p>As a consumer, subscribe and get the messages. Kafka runs in the cluster. We are going to call the different servers or nodes as <strong><em>brokers</em></strong>.</p><p>Kafka has four main API</p><ul><li>Producer API</li><li>Consumer API</li><li>Streams API</li><li>Connector API</li></ul><p>we can find more on the <a href="https://kafka.apache.org/10/documentation/streams/architecture">official blog</a></p><h4>Diving into Components ,Partition &amp; Replication</h4><p><strong><em>Components: Topic</em></strong></p><p>Kafka stores and organizes messages as a collection. They are known as Topics.</p><p><strong><em>Partition &amp; Replication</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*_44wsEZv1-k14yQ-qdMJ_A.jpeg" /></figure><p>we can replicate and partition Topics. From the above image, we see that a topic can have multiple partitions. Partitions are how we parallelize the topic. So if we have a lot of data in a certain topic and some systems will have a lot of data we want to have it on more than a single machine. So we partition it into multiple partitions. And then we can put each partition on a separate machine. It allows we more memory, more disk space. Consumers can also parallelize. So we can have multiple consumers on the same topic, each reading different partitions. So it actually allows us to get more throughput out of the system</p><p>Inside a partition, we see that each message has an ID. Those IDs are called offsets When we consume messages, we say I want to consume messages from this offset and continue on. And then if, for example, we break the connection and we want to start again, we can decide which offset we want to start with. And Kafka preserves the order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CKszdTNT8rPcYqPc.png" /><figcaption>Kafka Official Site</figcaption></figure><p>So producer writes into a topic, it writes messages in a certain order, and then it gets all those offsets in the same order. And we read them and we know that we are getting them in the same order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/0*Rs9cgPz2fUSv_pUv.png" /><figcaption>credits: Apache Kafka site</figcaption></figure><p>So we can see partitions 0, 1, and 2. each partition has multiple replicas. That’s how we do high availability. So the partition has copies on different servers. If the server goes away, we roll to a different topic.</p><h4>Components: Kafka Producer</h4><ul><li>pushes messages to a Kafka topic. Also responsible for choosing which record to assign to which partition within the topic.</li></ul><h4>Components: Kafka Consumer</h4><ul><li>subscribes to a topic pulls/ reads and processes messages from the topic.</li></ul><h4>Components: Kafka Broker</h4><ul><li>Broker known as Servers/Instances manages the storage of messages and exchange of messages. In a cluster, there are multiple Brokers</li></ul><h4>Components: Kafka Zookeeper</h4><ul><li>To offer the brokers with metadata about the processes running in the system and to facilitate health checking and broker leadership election, Kafka uses Kafka zookeeper.</li></ul><h3>Features of Kafka</h3><p>Like I said before, Kafka is not just a messaging system. It has more to it which makes it more standout from the other platforms. Following are some of those features.</p><ul><li>Scalability :</li></ul><p>Since Kafka has a distributed architecture, it gives the capability of scaling horizontally. This is achieved by partitioning the topic and distributing it to different nodes. Another thing that helps with scalability is Consumer groups. These two concepts combined together to ensure that there is no down time during a scaling process.</p><ul><li>Fault Tolerance</li></ul><p>If there is N replicas in the cluster, the Kafka cluster can tolerate upto N-1 failures. This ensures the availability as well as recovery of data in a dead Controller scenario</p><ul><li>Zero Data Loss</li></ul><p>Since writing process is synchronous and acknowledgement is sent to the client after the replication process, Kafka cluster guarantees that no data is lost.</p><ul><li>Durability</li></ul><p>Kafka cluster is writing the data into the disk in each transaction, hence, its data is durable. This feature is total contradiction with compared to Redis clustering.</p><ul><li>Stream Processing</li></ul><p>Kafka’s specialty lies in processing the streams of data. They have a special dedicated Stream API for this purpose. It has many functionalities like aggregations, joins, etc.</p><h3>Setting up a Kafka server on Ubuntu</h3><p>Prerequisite: JVM</p><p>Download the Kafka from <a href="https://www.apache.org/dyn/closer.cgi?path=/kafka/2.2.0/kafka_2.12-2.2.0.tgz">here</a> or by the following command in terminal</p><pre>wget <a href="https://www.apache.org/dyn/closer.cgi?path=/kafka/2.2.0/kafka_2.12-2.2.0.tgz">https://www.apache.org/dyn/closer.cgi?path=/kafka/2.2.0/kafka_2.12-2.2.0.tgz</a></pre><p>Let’s extract the file by the following command</p><pre>tar -xzf kafka_2.12-2.1.1.tgz</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GSVcR3TVNtTVyR2IecC_CA.png" /><figcaption>after extract</figcaption></figure><p>cd into extracted directory and start the zookeeper first</p><pre>bin/zookeeper-server-start.sh config/zookeeper.properties</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-m62CphMwlX3XrC9BRqJOA.png" /><figcaption>this means zookeeper started</figcaption></figure><p>Let&#39;s start Kafka server</p><pre>bin/kafka-server-start.sh config/server.properties</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*taT0ajfiBeDLj50nGDZdmw.png" /></figure><p><strong>Create a Topic</strong></p><p>I am creating a topic called <em>TutorialTopic</em></p><pre>bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic TutorialTopic</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8WpEdFFVKrD6vEKMkyA8w.png" /></figure><p>Let’s see the topic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YAnqaFfL5VhRqKSExJFKw.png" /></figure><pre>bin/kafka-topics.sh --list --zookeeper localhost:2181</pre><p>Let’s Push a message to the <em>TutorialTopic</em> we created</p><pre>echo &quot;Hello, World&quot; | bin/kafka-console-producer.sh --broker-list localhost:9092 --topic TutorialTopic &gt; /dev/null</pre><p>Let’s put another message to check in which order it reads later. with the following message <em>“Hello, from Kekayan”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xlJWQJrgd4HYpo61NvrbbA.png" /><figcaption>push the second message</figcaption></figure><p>Let’s check/Pull the Topic to see the message</p><pre>bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic TutorialTopic --from-beginning</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pt0RjmQtNlyzzNPBb5mxaA.png" /><figcaption>we can see first it read the first written one since we give tag from-beginning</figcaption></figure><p>as following image shows by running both sides by side we can see the how producer-consumer works .when we push it appears in consumers console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GOSnwtod0khAXLVQTDPcXA.png" /></figure><h3>Setting Up a Kafka Cluster</h3><p>we have played with a single broker, the real fun is playing with multiple cluster.let’s do it. First, we create the config files for the other two servers.</p><pre>cp config/server.properties config/server-1.properties<br>cp config/server.properties config/server-2.properties</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IrE4RMTeMSq6cFLFrWqAQw.png" /></figure><p>edit config for both new configs as follows</p><p>config/server-1.properties:</p><pre>broker.id=1</pre><pre>listeners=<a href="plaintext://:9093">PLAINTEXT://:9093</a></pre><pre>log.dirs=/tmp/kafka-logs-1</pre><p>config/server-2.properties:</p><pre>broker.id=2</pre><pre>listeners=<a href="plaintext://:9093">PLAINTEXT://:9094</a></pre><pre>log.dirs=/tmp/kafka-logs-1</pre><p>The broker.id property is the unique and permanent name of each node in the cluster. We have to change the port and log directory only because we are running these all on the same machine.</p><p>now start these two servers</p><pre>bin/kafka-server-start.sh config/server-1.properties <br>bin/kafka-server-start.sh config/server-2.properties </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*faNfL7f5qWtZkf-Yq0rN6Q.png" /></figure><p>Let’s create a new topic with replication factor 3 since we have 3 servers now.I name it as <em>clusterTopic</em></p><pre>bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic clusterTopic</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CBkXKH3iXlP9Qie9bYU-cQ.png" /><figcaption>ClusterTopic created</figcaption></figure><p>Let’s check the topic</p><pre>bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic clusterTopic</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNXNNsEhIlXq2JyrbxLRkw.png" /><figcaption>we can see 3 replications</figcaption></figure><p>Let’s create another topic with 2 partitions</p><pre>bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 2 --topic clusterPartionTopic</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOpueiubx4lk7SpmG5irEQ.png" /><figcaption>we can see 2 partitions now</figcaption></figure><p>Now we can use one as producer and others and itself as the consumer to check the cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPr-NNV5blEmIpsXB-h9FA.png" /></figure><pre>#create a producer<br>bin/kafka-console-producer.sh --broker-list localhost:9092 --topic clusterPartionTopic</pre><pre>#consumer 1<br>bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic clusterPartionTopic --from-beginning<br>#consumer 2<br>bin/kafka-console-consumer.sh --bootstrap-server localhost:9093 --topic clusterPartionTopic --from-beginning<br>#consumer 3<br>bin/kafka-console-consumer.sh --bootstrap-server localhost:9094 --topic clusterPartionTopic --from-beginning</pre><p>happy clustering :)</p><p><em>PS: I got great help and information from official site check it for further </em><a href="https://kafka.apache.org/quickstart"><em>https://kafka.apache.org/quickstart</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eac0eaf08a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Step by Step guide for Redis cluster in AWS]]></title>
            <link>https://kekayan.medium.com/redis-on-aws-36ed7054357e?source=rss-4e57f49ef8f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/36ed7054357e</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cluster]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Kekayan]]></dc:creator>
            <pubDate>Fri, 22 Mar 2019 04:26:22 GMT</pubDate>
            <atom:updated>2019-03-22T05:17:18.257Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome back to another Step by step guide,this time both with the explanation of the theory and practical as always. Let’s dive in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*awjtGyv0MjkX87M1.jpg" /></figure><ol><li>what is Redis</li><li>Under the hood of the Cluster</li><li>Redis cluster on AWS</li><li>Master-Slave Replication</li><li>Fail Over Simulating</li></ol><h3>1. What is Redis? ( REmote DIctionary Server)</h3><p>Redis is an in-memory<strong><em> </em></strong>database, simply which means Redis runs on RAM, which is also a key-value pair database &amp; widely used<strong> </strong>as a caching database. According to db-engines.com (a site which ranks the databases), Redis is in the top for key-value pair database. The key space is split into 16384 slots, so the max size for the cluster is 16384 master nodes (But a max size of nodes is in the order of ~ 1000 nodes). With Redis, we can use replication, sharding, or both.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vB6DTeT51Fnz7crG-DoUNg.png" /><figcaption><a href="https://db-engines.com/en/ranking/key-value+store">https://db-engines.com/en/ranking/key-value+store</a></figcaption></figure><p>Formal definition from the Redis official site.</p><blockquote>Redis is an open source (BSD licensed), in-memory <strong>data structure store</strong>, used as a database, cache and message broker. It supports data structures such as <a href="https://redis.io/topics/data-types-intro#strings">strings</a>, <a href="https://redis.io/topics/data-types-intro#hashes">hashes</a>, <a href="https://redis.io/topics/data-types-intro#lists">lists</a>, <a href="https://redis.io/topics/data-types-intro#sets">sets</a>, <a href="https://redis.io/topics/data-types-intro#sorted-sets">sorted sets</a> with range queries, <a href="https://redis.io/topics/data-types-intro#bitmaps">bitmaps</a>, <a href="https://redis.io/topics/data-types-intro#hyperloglogs">hyperloglogs</a>, <a href="https://redis.io/commands/geoadd">geospatial indexes</a> with radius queries and <a href="https://redis.io/topics/streams-intro.md">streams</a>. Redis has built-in <a href="https://redis.io/topics/replication">replication</a>, <a href="https://redis.io/commands/eval">Lua scripting</a>, <a href="https://redis.io/topics/lru-cache">LRU eviction</a>, <a href="https://redis.io/topics/transactions">transactions</a> and different levels of <a href="https://redis.io/topics/persistence">on-disk persistence</a>, and provides high availability via <a href="https://redis.io/topics/sentinel">Redis Sentinel</a> and automatic partitioning with <a href="https://redis.io/topics/cluster-tutorial">Redis Cluster</a>.</blockquote><h3>2. Under the hood of the Cluster</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3bU4PjC3u3YboSc9tW6zFQ.png" /><figcaption>simple cluster client communication</figcaption></figure><p>In Cluster nodes have Heartbeat procedure it makes them auto-discover other nodes, detect non-working nodes or Failing nodes, and promote slave nodes to master when needed in order to continue to operate when a failure occurs. All nodes/servers are directly connected with a service channel. To perform their tasks all the cluster nodes are connected using a TCP bus and a binary protocol, called the Redis Cluster Bus. Each node in the cluster uses a gossip protocol to communicate information about the cluster in order to discover new nodes, to send the ping to other nodes to make sure all the other nodes are working and to send cluster messages needed to signal specific conditions.</p><blockquote>Ping uses the ICMP(Internet Control Message Protocol) to send and receive echo messages from and to the host and destination computers respectively to tell us about the performance of the network.</blockquote><p><strong>what happens between nodes to nodes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VWPLA3A60YBCIQIJsHzBoA.png" /><figcaption>two nodes communication between them</figcaption></figure><ul><li>They ping pong to check health .if we imagine it ‘ll be like below</li></ul><pre>Node 1 will ping<br>PING: are you ok dude? I’m master for XYZ hash slots.</pre><pre>Node 2 will reply<br>PONG: Sure I’m ok dude! I’m master for XYZ hash slots.</pre><ul><li>They use gossip to share info .if we imagine it ‘ll be like below</li></ul><pre>Node 1 Gossip to Node 2: these are info about other nodes<br>                         I&#39;m in touch with:<br>               Node 3 replies to my ping, I think its state is OK.<br>               Node 4 is idle, I guess it&#39;s having problems</pre><pre>Node 2 Gossip to Node 1: these are info about other nodes<br>                         I&#39;m in touch with:<br>               Node 3 are fine and replied in time.<br>               Node 4 is idle,  for me as well! May be down :(</pre><blockquote>There are two flags that are used for failure detection that are called <em>PFAIL</em> and <em>FAIL</em>. <em>PFAIL</em> means <em>Possible failure</em>, and is a non-acknowledged failure type. <em>FAIL</em> means that a node is failing and that this condition was confirmed by a majority of masters within a fixed amount of time.</blockquote><p><em>Above quoted one was taken from Redis official site. we find more info about Failure detection on </em><a href="https://redis.io/topics/cluster-spec"><em>Redis site</em></a></p><h4>Replication</h4><p><a href="http://en.wikipedia.org/wiki/Replication_%28computing%29#Database_replication">Replication</a>, also known as mirroring, means copying all of the data to another location. This allows data to can be accessed from two or more locations, which ensures high availability. In other words, the replication process provides the facility for multiple reads or sorts at a time.</p><p>Another situation where Replication becomes quite handy is when one or few data locations (or Availability Zones) went down. The data associated with the lost node is still retrievable since one of the lost master’s slave will take up its position and serve the cluster like its master did since it has all the data from its master.</p><p>In Redis, we can set up replication by using a master-slave(s) setup for replication. In simple words, the master is the main node and slave(s) copies all the things from the master, so that, a slave can replace its master in case of failure. We will see this clearly in the hands-on part.</p><h4>Sharding</h4><p><a href="http://en.wikipedia.org/wiki/Shard_%28database_architecture%29">Sharding</a>, also known as partitioning, involves splitting data up based on key spaces. It is the mechanism behind clustering and scaling in Redis.</p><p>There are 16384 conceptual key spaces (Hash Slots) in Redis. What we do in sharding is divide this key spaces into multiple nodes instead of a keeping in a single node. It will make this key spaces larger and capable of keeping more and more data. For example, If you build up a cluster with 3 masters like recommended by the Redis.io, it will divide the KeySpace like:</p><ul><li>Slot 0 to 5000 → Master 1</li><li>Slot 5001 to 10500 → Master 2</li><li>Slot 10501 to 16384 → Master 3</li></ul><p>Assume that you have 16GB RAM machine. If you use 3 machines like that, for the Redis clustering, you will end up having 48GB RAM space. Hence, your one Keyspace will be larger in terms of size.</p><p>This increases performance because it reduces the hit on each of the individual resources, allowing them to share the load rather than having it all in one place.</p><h3>3. Redis Cluster setup in AWS</h3><ol><li><strong>Let’s create 4 EC2 instances</strong></li></ol><p>Login to your AWS console and in services select ec2.Then click launch instance.</p><p>for this tutorial, I am creating t2.micro instances which have 1GB RAM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AWpOWUUFADNdPhQZhFqMAg.png" /><figcaption>Launching ec2</figcaption></figure><p>In the next step, I specified 4 instances as Number of instances to launch. The create key pair for ssh access and launch .you will see all 4 instances launched</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6z-w-yzDJfogBFTilRR9g.png" /><figcaption>ec2 dashboard after 4 instances created</figcaption></figure><p>2.Install the Redis</p><p>We’ll install the Redis in <strong><em>Redis1, Redis2, Redis3 machines and</em></strong> keep the <strong>Redis4</strong> for master-slave replication configuration later.</p><p><strong>steps we need to follow in each 3 servers</strong></p><ul><li>Download and Extract Redis</li><li>Install build-essential, make</li><li>Make Redis libraries</li><li>Install tk8.5 tcl8.5 — (C functions/Libraries)</li><li>Update configuration (redis.conf)</li><li>Start Redis Server</li></ul><p>first, we log in to every 3 servers using ssh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJSUhzIE4oUEoRy4LHlo3A.png" /><figcaption>after login to all 3 servers</figcaption></figure><p><strong>Download and Extract Redis</strong></p><p>You can use apt based packages also. In this guide, we will see the building from source.</p><p>you can simply get this script and run as a bash script or run each one by one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c27117916a8a1fab5e7bb8f9295526be/href">https://medium.com/media/c27117916a8a1fab5e7bb8f9295526be/href</a></iframe><p>Let’s create a directory called build and in that directory. Let’s Download Latest version of the Redis using wget. Finally, extract it and cd to the folder for the next step</p><p><strong>Install build-essential, make</strong></p><p>Since we are gonna build we need gcc and make so let’s first download and install them and build.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e53114e25aa5b92d1b9e2c493e04e059/href">https://medium.com/media/e53114e25aa5b92d1b9e2c493e04e059/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5FUT4MNqkNvYsnYxxAbFcQ.png" /></figure><p>Now run the following command</p><p>we are gonna set memory allocators as libc</p><pre>make MALLOC=libc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VmbuZhgCtISpS0tOh9Eyfg.png" /></figure><p>let’s run some tests to verify</p><pre>sudo apt-get install -y tk8.5 tcl8.5 <br>make test</pre><p>It will take some minutes to finish all the 50 tests. You should see a lot of green [ok] messages like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aw-VgtjwdKkXvSB8-uS9Mg.png" /></figure><p>If you reached this step without issues:).You have to build Redis Now Let’s Configure and run</p><p><strong>Let’s update the configurations</strong></p><p>Use your favourite editor like nano or vim to open config file.</p><pre>sudo nano redis.conf</pre><p>Modify these lines on each server in Redis.conf file as following. You can use ctrl+w in nano editor to search.</p><p>change &lt;privateIp&gt; to respective private IP addresses</p><pre>bind &lt;privateIp&gt; 127.0.0.1 ::1<br>cluster-enabled yes<br>cluster-config-file nodes-6379.conf<br>cluster-node-timeout 5000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cd7ZWOL8530qRScWRUc4mg.png" /><figcaption>config file</figcaption></figure><p>Next start Redis Server On all 3 nodes</p><pre>src/redis-server ./redis.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ps6gSJdQSR9-XJO-1Ihmw.png" /><figcaption>All 3 servers started</figcaption></figure><p><strong>Now we need to connect them as the cluster.</strong></p><p>So in our AWS EC2 security groups enable TCP over port 6379 and 16379.</p><p>Let’s cd to Redis</p><pre>cd build/redis-5.0.4/</pre><p>Now we need to install Redis CLI. Since we are going to use Ruby based Redis CLI. We install Ruby package manager to install it.If you get any issues skip next 3 steps and use the apt based repo to install cli.</p><p>Install GPG keys</p><pre>sudo apt install gnupg2<br>gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB</pre><p>Install RVM</p><pre>\curl -sSL <a href="https://get.rvm.io/">https://get.rvm.io</a> | bash -s stable</pre><p>Install ruby &amp; Redis</p><pre>source ~/.rvm/scripts/rvm rvm requirements<br>rvm install ruby <br>gem install redis</pre><p>if the above 3 steps failed for you try this</p><pre>sudo apt  install ruby<br>sudo gem install redis</pre><p>Install Redis CLI</p><pre>sudo apt install redis-tools</pre><p><strong>Create Connection</strong></p><p>replace &lt;ips&gt;: port with correct values and run below command to create a cluster</p><pre>redis-cli --cluster create &lt;publicip1&gt;:port &lt;publicip2&gt;:6379 &lt;publicip3&gt;:6379</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e_3cFp2hSEY9eBbcnbNaEQ.png" /><figcaption>Cluster Created and slots allocated to each node</figcaption></figure><p>Now finally we Test our cluster in a different node by running following command (replace IP)</p><pre>src/redis-cli -h &lt;privateip&gt; cluster nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K4szSYhjiUXCRn2DZkTMig.png" /><figcaption>cluster nodes</figcaption></figure><h3>4. Master-Slave asynchronous Replication</h3><p>Master-Slave replication allows replicating data written to the master instance to a slave instance and allows slave Redis servers to be exact copies of their master servers. Replication is asynchronous because of performance concerns. But on the other hand, it means that Redis does not guarantee strong data consistency, which means, it is not possible to ensure the slave actually received a given write, so there is always a window for data loss.</p><p>There is another caching database called <strong>Scaled Out State Server</strong> which guarantees for no window for data loss .check my write up in <a href="https://medium.com/@kekayan/a-step-by-step-guide-for-manual-setting-up-scaleout-stateserver-in-aws-58e594ca0cd1">medium</a> about it.</p><p>I am here only doing for one server a salve. You can reproduce for other servers to ensure 3 slaves are available for each 3 masters.</p><p>we can use same servers for master salve like below which is known as cross replication. but for easiness of understanding .i ll configure a new server as salve.So you can visualize easily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmxRUfaem1YFaNmIlWYmbg.png" /></figure><ol><li>Install Redis on the new server</li></ol><p>I am using apt based methods here since i have told how to do it from source.</p><pre>sudo apt-get install redis-server <br>sudo apt-get install redis-tools</pre><p>2.Configure slave</p><p>configuration file is located on /etc/redis/. Let’s edit</p><pre>sudo nano /etc/redis/redis.conf</pre><p>Edit as Following in config</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7M-sPxUcVwR9Uf9ScnTfdA.png" /></figure><pre>bind 172.31.42.94 #Private IP <br>slaveof 172.31.42.93 6379 #Redis Cluster Node2</pre><p>Or run this command in a master</p><pre>redis-cli --cluster add-node slaveip:port masterip:port --cluster-slave</pre><p>Finally, start the slave server</p><pre>sudo redis-server /etc/redis/redis.conf</pre><p>In case If you want cross replication copy the redis.conf to another name and start new Redis server by</p><pre>sudo redis-server /etc/redis/new-redis.conf</pre><p>And do above setup for the master-slave configuration. With different port don’t forget to change the cluster config file and port in slave configuration files</p><p><strong>Testing the cluster</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jRM5gyPlGJ6rQc2oTRi9pA.png" /><figcaption>we can add key value to one server and receive or retrieve on another server</figcaption></figure><p>Run following command in two servers</p><pre>redis-cli -c -p 6379</pre><p>in on server</p><pre>set key value</pre><pre>example :</pre><pre>set kekayan medium-blog</pre><p>another server lets get it</p><pre>get key</pre><pre>example :</pre><pre>get kekayan</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7k1gC4nN9QdCrTaQmcGRSw.png" /><figcaption>add &amp; retrieve key value pairs</figcaption></figure><h3>5.Simulating Fail-over</h3><p>While i putting data, I have stopped one Redis instance which was a master and restarted it after some time. Now it runs as a slave.</p><pre>#to get all nodes<br>redis-cli -p 6379 cluster nodes</pre><pre># to get only master nodes<br>redis-cli -p 6379 cluster nodes | grep master</pre><p>So how did that happen? Let me explain:</p><p>When a master fails, other nodes in the cluster gets to know it by the gossip port. Then what happens is all masters get together and cast vote for promoting one of the failed master’s slave as a new master. Highest voted slave become the new master and manage the key spaces that failed master had managed.</p><p>When the failed master recovers from failure and try to join the cluster again, his spot as a master is already occupied by the new master. Therefore, he has to become a slave in the cluster.</p><p>This is why my stopped node have become a slave when I restarted it.</p><p>That’s it for now</p><p>If you want further info or stuck in some steps feel free to ask in comments :)</p><p>Happy Hacking :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36ed7054357e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A step by step guide for manual setting up ScaleOut StateServer in AWS]]></title>
            <link>https://kekayan.medium.com/a-step-by-step-guide-for-manual-setting-up-scaleout-stateserver-in-aws-58e594ca0cd1?source=rss-4e57f49ef8f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/58e594ca0cd1</guid>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[distributed-cache]]></category>
            <category><![CDATA[scale-out]]></category>
            <category><![CDATA[sateserver]]></category>
            <dc:creator><![CDATA[Kekayan]]></dc:creator>
            <pubDate>Sat, 01 Dec 2018 03:40:34 GMT</pubDate>
            <atom:updated>2018-12-03T09:00:05.244Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdmhSreAG6Nv7MEIp4BkIw.png" /></figure><p>I wanted to keep a note on what i did to setting up the ScaleOut StateServer in AWS EC2 instances. Because cloud vendors don’t support multicast .So we have to use unicast here.So it’s a bit difference process.I am just sharing a draft here.Hope it will be helpful</p><h4>Why State Servers?</h4><blockquote>Spurred by the growth of Web-based applications running on server-farms, a new category of data is beginning to play a key role in driving high performance. Called workload data, this information claims the unique properties of being simultaneously mission critical, frequently accessed, and often short lived. Workload data can either be generated by the application or it can represent data cached from recent access to a database server. Examples include intermediate business logic state, Web session-state, and cached data sets.</blockquote><blockquote>Distributed caching enables server-farms to meet the new performance, scalability and availability challenges created by the management of workload data.</blockquote><p>above quoted paragraph taken from scale-out white paper explains well.For the full paper <a href="https://www.scaleoutsoftware.com/wp-content/uploads/2015/03/SOSS_DistCacheWP.pdf">click here</a> .</p><h4>more links</h4><p><a href="https://www.scaleoutsoftware.com/better-than-redis/">Redis vs ScaleOut</a></p><h3>Now Dive in to setting up ScaleOut State Server</h3><ol><li><strong>Register and Get the Trail license</strong></li></ol><p>You can get evaluation license for 30 days which limited to 1 host server <a href="https://www.scaleoutsoftware.com/try-for-free/">here</a>.But in this guide we are going to create a grid with at least 2 scaleout host servers.So you have to mail them and get the evaluation key for that we can mail to<strong> support@scaleoutsoftware.com </strong>to obatain a demo license according to our need for demo purposes which have 60days of time .</p><p><strong>2. Create an EC2 Instance</strong></p><p>Login to your aws console and select EC2 Services and Launch instance.I am selecting ubuntu 18.04 AMI and t2.micro instance which is on free tier.I am going with default VPC and moving forward <strong>important</strong> part is in the “<em>Step 6: Configure Security Group</em>” here we have to setup TCP rule over the port 720–724 to our vpc network and the remote client/application server ips.Yoiu can find your VPC network sub net ip in VPC service since i am using default it will be 172.31.0.0/16 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9fzogHFglsZ4fHowC3qeg.png" /><figcaption>sample security group</figcaption></figure><p>Finally create the key and launch the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8_wD_9KKMi4ummo5mQb0ng.png" /><figcaption>create 2nd instance by clicking launch more like this</figcaption></figure><p>Then create two elastic ips and associate with instances .If you feel any difficulty ask in comment section :) .</p><h4><strong>2.Install SOSS / ScaleOut StateServer</strong></h4><p>ssh to your instances from terminal. I am doing parallel in both instances</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_mGQhRLNIWk86IdzoH3M1A.png" /></figure><p>To download scaleout stateserver run</p><pre>wget <a href="https://www.scaleoutsoftware.com/pkg/soss_5.8.1.331_amd64.deb">https://www.scaleoutsoftware.com/pkg/soss_5.8.1.331_amd64.deb</a></pre><p>To install</p><pre>sudo dpkg -i soss_5.8.1.331_amd64.deb</pre><h4>3.Configurations</h4><p>Now add license and change other parameters</p><pre>cd /usr/local/soss<br>nano soss_params.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ul2aeH9DsDEuraHtEm1RIQ.png" /></figure><p>Change below parameters</p><ol><li>net_interface — 172.31.0.0 (our vpc IPv4 )</li><li>subnet_mask — 255.255.0.0 (since vpc cidr is 16)</li><li>use_multicast — 0</li><li>license_key — the one you obtained from mail</li><li>gateway_ip — the public ip of the instance</li><li>auto_join — 1</li></ol><p>After the changes save the text file. And run terminal command</p><pre>SOSS restart</pre><p>so changes will take effect</p><p>Then disconnect from existing group by</p><pre>soss disconnect</pre><p>And create a new host group in the first server you do only.</p><pre>soss create_group</pre><p>In the second server just change as above without creating group run below command to join that group</p><pre>soss add_host privateip of the 1st host</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t4AXnbJOBp4agAWFw0R8wA.png" /><figcaption>other servers</figcaption></figure><p>now run query to check the host group servers</p><pre>soss query all</pre><p>This will display group of ips.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*MnaBg1SSA3N3T7sIQaEitw.png" /></figure><p>You can now use your client to communicate with the state server :)</p><p>If you are interested to know more on how to add retrieve update data.how to write callback function when TIME-TO-LIVE is over comment to the post I ll write in next post</p><p>Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58e594ca0cd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encrypt files using AES with OPENSSL]]></title>
            <link>https://kekayan.medium.com/encrypt-files-using-aes-with-openssl-dabb86d5b748?source=rss-4e57f49ef8f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/dabb86d5b748</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[openssl]]></category>
            <category><![CDATA[encrypt]]></category>
            <category><![CDATA[ea]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Kekayan]]></dc:creator>
            <pubDate>Sat, 07 Jul 2018 14:16:17 GMT</pubDate>
            <atom:updated>2018-07-07T14:17:19.714Z</atom:updated>
            <content:encoded><![CDATA[<p>In this simple post i will simply explain how to encrypt decrypt files using <em>AES</em> with openssl.</p><h3><strong>What is OPENSSL?</strong></h3><blockquote><em>Cryptography and SSL/TLS Toolkit</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*qhsAI9FUFokdtV1x73dbug.png" /><figcaption><a href="https://www.openssl.org/">https://www.openssl.org</a></figcaption></figure><p>OpenSSL is a program and library that supports many different cryptographic operations, including:</p><p>Symmetric key encryption<br>Public/private key pair generation<br>Public key encryption<br>Hash functions<br>Certificate creation<br>Digital signatures<br>Random number generation</p><p>Each of the operations supported by OpenSSL have a variety of options, such as input/output files, algorithms, algorithm parameters and formats.</p><h3>what is AES?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RshQA9waAi-S7vdZkOKN6A.jpeg" /></figure><p>AES — Advanced Encryption Standard (also known as Rijndael), is a symmetric-key algorithm which means it uses the same key during encryption/decryption.</p><p>Let’s start</p><p>The list of supported ciphers can be viewed using following command</p><pre>openssl list-cipher-commands</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a1YE6W8TSvopVdvlqt86YQ.png" /><figcaption>A part of the algorithams in the list</figcaption></figure><p>Here I am choosing -aes-26-cbc</p><p>Symmetric key encryption is performed using the enc operation of OpenSSL.</p><p>1.We can specify the password while giving command</p><p>2.We can enter when it promoted</p><p>Let’s do the first method as first</p><p>First i made a folder in my Desktop named “open_ssl” using commandmkdir</p><p>Here i put the file which i wanted to encrypt (a image file) “image.png” ,</p><h3>Now is the time to encrypt our image</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yO-u_9DnpWavUq90b7Vx9A.png" /></figure><p>As you see above screenshot the folder “openssl_aes” has only one image file which we are going to encrypt.</p><pre>openssl enc -aes-256-cbc -pass pass:kekayan -p -in image.png -out file.enc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4cyMTyXX0zucaiiScFBxpQ.png" /></figure><p>So now you can see the image is encrypted and the salt ,key and iv values.</p><p>Below image we can verify that new file name “file.enc” created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtb1QY7MPlj4elwPD4NR3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jMCna4KAfDlwRiHDjX3ldQ.png" /></figure><p>let’s find out each part in our code</p><ul><li>-aes-256-cbc — the cipher name( symmetric cipher : AES ;block to stream conversion : CBC(cipher block chaining))</li><li>-pass pass:&lt;password&gt; — to specify the password (here password is kekayan)</li><li>-P — Print out the salt, key and IV used.</li><li>-in file— input file /input file absolute path(here image.png)</li><li>-out file— output file /output file absolute path(here file.enc)</li></ul><h3>Let’s Decrypt the encrypted image</h3><pre>openssl enc -aes-256-cbc -pass pass:kekayan -d -in file.enc -out img_new.png -P</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNKrctcvUvhjs_rZJVd16g.png" /></figure><p>After decrypted .Now you can see new image named “img_new.png” also in the folder.</p><p>let’s find out each part in our code</p><ul><li>-d — Decrypt the input data.</li><li>-in file— input file /input file absolute path(here file.enc)</li><li>-out file— output file /output file absolute path(here image_new.png)</li><li>-P — Print out the salt, key and IV used.</li></ul><p><strong><em>Beware of the line breaks</em></strong></p><p>While working with AES encryption I encountered the situation where the encoder sometimes produces base 64 encoded data with or without line breaks.To solve this simply add -A</p><p>So It will be like this</p><pre>openssl enc -aes-256-cbc -pass pass:kekayan -d -A -in file.enc -out img_new.png -p</pre><ul><li>-A — base64 encode/decode, depending on encryption flag.</li></ul><p>openssl enc --help for more details and options (e.g. other ciphernames, how to specify a salt,etc).</p><h3>Let’s do without specify password flag</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-LPxa-Q3pLPYJFZ77Avig.png" /></figure><h4>Following command for encrypt:</h4><pre>openssl enc -aes-256-cbc  -p -in image.png -out file.enc</pre><p>It will prompt you to enter password and verify it.</p><h4>Following command for decrypt</h4><pre>openssl enc -aes-256-cbc  -d -A -in file.enc -out img_new.png -p</pre><p>Here it will ask the password which we gave while we encrypt.</p><ul><li>-nosalt —not to add default salt</li></ul><p>Most cases salt is default on.you can specify it using -Salt</p><p>Also you can specify the salt value with the -S flag.If you provide the salt value, then you become responsible for generating proper salts, trying to make them as unique as possible (in practice, you have to produce them randomly). It is preferable to let openssl handle that.</p><p>When the salt is being used the first eight bytes of the encrypted data are reserved for the salt: it is generated at random when encrypting a file and read from the encrypted file when it is decrypted.</p><p>So if you open file.enc in a text editor you will see like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ga6zl4UjPuovgJFe-JGaIw.png" /></figure><pre>Salted__</pre><p>Happy encrypting :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dabb86d5b748" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Display your Resume/CV PDF in website using GitHub]]></title>
            <link>https://kekayan.medium.com/display-your-resume-cv-pdf-in-website-using-github-73a088ac961d?source=rss-4e57f49ef8f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/73a088ac961d</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[cv]]></category>
            <category><![CDATA[resume]]></category>
            <dc:creator><![CDATA[Kekayan]]></dc:creator>
            <pubDate>Tue, 08 May 2018 05:32:32 GMT</pubDate>
            <atom:updated>2018-05-08T05:39:48.650Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHcZjkW-s6cz3Es_fqVWEg.png" /></figure><p>It will be easy if we share our resume link to others than sharing the PDF file .I will share the steps which i followed to host mine.So it will be helpful to others.</p><p><strong>prerequisite: </strong><a href="https://github.com/">GitHub</a> account</p><p>So what we are trying to achieve is something similar to <a href="https://kekayan.github.io/resume/">https://kekayan.github.io/resume/</a> .Own a website which have your resume PDF .</p><h3>1.Create a public repository</h3><p>follow this link <a href="https://github.com/new">https://github.com/new</a> . so you ll see a site similar to this,now create a repo and name it as “resume”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*F686SkF6Z_hPad_i0ST7Ug.png" /><figcaption>create a repository in the name of resume</figcaption></figure><h3>2.Upload your resume PDF file</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*MrDasoXacEJIkw7n2hvmlQ.png" /></figure><p>After you created the repo . you will see like above screenshot.There click upload files. And upload and commit your pdf as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*ZX-C5aGmboDPxBRnE5RABA.png" /><figcaption>commit after uploading finish</figcaption></figure><h3>3.Get the pdf’s link</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kkdOd2LYJbuu2zqvIBFDgQ.png" /></figure><p>click the PDF file in your repo . you will see something similar to this.There right click in the download button and copy the link by “copy link address”</p><h3>4. Create a HTML file to view the pdf</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*9r_ToGdMV0nsj0GX_ZsDig.png" /></figure><p>replace “YOUR LINK HERE” with your copied link.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be22ed0dc67adcb49f921b2c1fd2b8ea/href">https://medium.com/media/be22ed0dc67adcb49f921b2c1fd2b8ea/href</a></iframe><h3>5.Github pages</h3><p>Now to go to the settings of the resume github repo.find the github pages settings and activate it for the master branch.You will see something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*25VdAh10YjKsi13HcgFrPA.png" /></figure><p>Finally you can see your resume in your site :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73a088ac961d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>