<?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 Catalin Carabas on Medium]]></title>
        <description><![CDATA[Stories by Catalin Carabas on Medium]]></description>
        <link>https://medium.com/@catalincarabas?source=rss-880e6e4a22ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*B89QlPapqpJeoWn_pkrGZw.jpeg</url>
            <title>Stories by Catalin Carabas on Medium</title>
            <link>https://medium.com/@catalincarabas?source=rss-880e6e4a22ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 04:00:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@catalincarabas/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[When Experts Are No Better Than a Dart-Throwing Chimp]]></title>
            <link>https://catalincarabas.medium.com/when-experts-are-no-better-than-a-dart-throwing-chimp-27e584ea6716?source=rss-880e6e4a22ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/27e584ea6716</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[decision-making]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[psychology]]></category>
            <dc:creator><![CDATA[Catalin Carabas]]></dc:creator>
            <pubDate>Mon, 02 Mar 2026 12:35:28 GMT</pubDate>
            <atom:updated>2026-03-02T12:35:28.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yXIYTBg7By06i2jM" /><figcaption>Photo by <a href="https://unsplash.com/@javaistan?utm_source=medium&amp;utm_medium=referral">Afif Ramdhasuma</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve run across this disturbing experiment. From 1984 to 2003, psychologist Philip Tetlock tracked 284 experts (government officials, professors, journalists) and had them make 82,361 specific predictions (e.g., “Will there be a coup in country X?“, “Will the Euro collapse?“).</p><p>The Results:</p><p><strong>The Chimp Benchmark: The average expert was only slightly more accurate than a “dart-throwing chimpanzee” (random chance).</strong></p><blockquote>It seems like the fundamental mechanism at play here is the “<strong><em>ability to fully explain the causal chain</em></strong>”.</blockquote><p>Let’s take 3 examples:</p><ol><li><strong>High degree of knowability of the causal chain: </strong>The car stops at 150 km per hour, so you ask the mechanic to fix it-&gt; He explains that this is because the radiator is broken, so the car overheats and shuts down -&gt; He changes the radiator and the car is fixed</li><li><strong>Low degree of knowability of the causal chain: </strong>The landing page converts at 30%, so you ask the designer to improve it -&gt; The designer says that chaining the CTA to red will have a big impact on conversion because red implies importance and urgency, so people will click it more -&gt; You change the button, and nothing happens</li><li><strong>No degree of knowability of the causal chain: </strong>Gambling, long-term geo-political predictions, stock picking ( without a clear edge ), etc. In these cases, one might create fake causations ( overfit ) like “Ah, this sports team usually wins when they play on a Thursday, and it rains,” and this overfitting increases confidence but not accuracy</li></ol><p>The difference between cases 1 and 2 is that in the first case, the causal chain is simple and expert knowledge can grasp it, while in the second case, the causal chain passes through the human brain, and the cause-and-effect relationships are fuzzy.</p><p>Depending on the degree of knowability, you must use <em>different strategies</em> to tackle the situations:</p><ul><li>High degree = <strong>Predictable</strong> = Learn more theory = The expert is a Map-Maker, so trust them.</li><li>Low degree = <strong>Discoverable</strong> = Experiment more = The expert is a<strong> </strong>Scout<strong>, </strong>so listen, but verify.</li><li>No degree = <strong>Unknowable</strong> = Use Risk management to estimate expected returns = The expert is a Storyteller, so ignore them.</li></ul><p>The problem comes when people confuse these categories.</p><p>We often talk about a Discoverable or an Unknowable system as if they are Predictable. <strong>People invent plausible-sounding explanations that seem to explain the causal chain, when in fact they do not.</strong></p><p>It’s easy to come up with convincing explanations and trick ourselves into believing something is predictable, and investing more than we should into sub-optimal initiatives.</p><p>For example: <strong>Tech dept from the perspective of team productivity.</strong> Is this a <em>predictable</em> or <em>discoverable</em> system? From past discussions, people talk about it as if it’s predictable: “<em>If we apply the principle of Separation of Concerns to this case, productivity will increase</em>”. But the causal chain is hard to explain:</p><ul><li>How exactly will &quot; Separation of Concerns &quot; lead to higher productivity in this instance?</li><li>How do you measure the effects?</li><li>How do you know that the biggest point of friction is a poor Separation of Concerns?</li></ul><p>The “productivity” aspect of a tech team, especially as it relates to technical debt, is a fuzzy problem that passes through the human brain. Things like familiarity and simplicity might matter a lot, and these depend on the team&#39;s existing expectations, preferences, habits, etc. This system behaves more <em>discoverable</em> from this perspective.</p><p>But it&#39;s also easy to trick ourselves into believing that something is not predictable in order to avoid doing the hard research work upfront.</p><p>Every <strong>Category Error </strong>here has a cost:</p><ul><li>Treating<strong> Predictable </strong>problems as<strong> Discoverable</strong> leads to “reinventing the wheel” and wasted effort. You don’t need an A/B test to see if a car needs a radiator. <strong>Learn the theory.</strong></li><li>Treating<strong> Discoverable </strong>problems as<strong> Predictable</strong> leads to missed bets and rigid failure. High-level “best practices” won’t help if the team dynamic doesn’t support it. <strong>Run an experiment.</strong></li><li>Treating<strong> Unknowable </strong>problems as<strong> Predictable</strong> leads to dangerous overconfidence. You aren’t “calculating” the next black swan; you’re just telling a story. <strong>Manage the risk.</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27e584ea6716" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Discovery: Why Learning is Key For Startup Success]]></title>
            <link>https://blog.startupstash.com/the-art-of-discovery-why-learning-is-key-to-start-up-success-f8bb4066a0c0?source=rss-880e6e4a22ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8bb4066a0c0</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[business-strategy]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Catalin Carabas]]></dc:creator>
            <pubDate>Mon, 06 Feb 2023 09:04:17 GMT</pubDate>
            <atom:updated>2023-02-08T11:44:41.003Z</atom:updated>
            <content:encoded><![CDATA[<p>A start-up’s success, especially one that tries to disrupt, has more to do with its ability to <strong>Discover</strong> valuable insights, than with its ability to <strong>Execute</strong> them.</p><p><em>( Discovery is not strictly related to customer wants, although that’s one of its most important parts. A business learning about a constant bottleneck in its supply, or that one of its core processes is deficient, or learning that there is a better solution for managing internal communication is also part of its Discovery process. )</em></p><p>The value curve of <strong>Execution</strong> it’s more like an <strong>S-shaped curve</strong>, with a middle point determined by the market expectations compared with other existing solutions.</p><ul><li>If you are too much below the inflexion point, the implementation becomes mostly unusable</li><li>If you are too much above the inflexion point, you’re probably experiencing rapidly diminishing returns.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VqM5nuwheI0MwlMXgmk8pg.png" /><figcaption>The value curve of Execution</figcaption></figure><p>That is because there is a limit to how much <strong>Execution</strong> can vary in terms of both <strong>quantity</strong> and <strong>quality</strong>.</p><p>A small team of developers, which is usually the case for a startup that does exploratory work, might pump up 10 features per week with a certain quality, or 20/30 features with less quality, but they won’t be able to pump up 50, or 100.</p><p><strong>Above a certain threshold, determined usually by the available technologies and best practices, there simply is no way to implement 10 times faster and still remain above the usability threshold.</strong></p><p>Even if the business decided to pay the cost and adopt better processes and technologies, the spectrum of possible ideas to be implemented is so vast, and so few of them will prove to be actually valuable, that even a 10x increase in execution will not be enough.</p><h4>Your goal as an organisation is to find your way to the sweet spot of Execution and then focus your resources on coming up with better ideas.</h4><p><strong>That is because two different ideas which are similar in terms of execution effort can differ by multiple orders of magnitude in terms of the value they can create.</strong></p><p>One might have no engagement, and the other might lead to the product becoming viral. This might be the only thing big enough to make the difference between a start-up that succeeds and one that doesn’t.</p><p>This is why the value curve of <strong>Discovery</strong> might actually be exponential and the more resources you put into a good discovery process, the more value it creates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eQ6uueJ-J61888ZQWZ6BAg.png" /><figcaption>The value curve of Discovery</figcaption></figure><p><strong>So how can an organisation become better at this nebulous skill of producing more effective ideas?</strong></p><p>The agile approach to discovery assumes that experimentation is the best process for discovering useful insights.</p><p>That is because contact with reality creates the most useful type of knowledge there is, tailored made for your market and product.</p><p>A start-up needs to be able to <strong>capture this knowledge</strong> and <strong>use it to guide the new features</strong>.</p><p>This is what <strong>Learning</strong> is all about.</p><p>In an unexplored space, it’s critical to this ability to learn efficiently, and that is, to capture as much relevant data produced by your product/process as possible and internalise it into the decision-making process.</p><p>A lot has been said about the ability to capture relevant product data, and there are tons of tools out there that allow you to do this in a bewildering amount of ways, but two things that usually get less attention are <strong>process knowledge</strong>, and how exactly can an organisation use all this captured knowledge.</p><p><strong><em>The thing with process knowledge is that it usually needs to come from people, rather than code, and it’s hard to capture consistent and accurate data from people.</em></strong></p><p>It’s important to have an insight-sharing culture that empowers all employees to share insights that they deem valuable in relation to the business priorities.</p><p>To ensure their insights are effectively captured and utilized, companies need to have a clear structure in place. This might involve creating a dedicated platform or channel where employees can share their thoughts and ideas, and it could also involve regular check-ins and feedback sessions to keep the lines of communication open. Having a culture of open communication and collaboration is also essential. Encouraging employees to share their insights and encouraging them to be a part of the decision-making process can help to foster a sense of ownership and accountability, and can lead to better outcomes for the business. It’s also important to keep in mind that capturing employee insights is not a one-time event but rather a continuous process. Companies should be proactive in seeking out insights and encouraging employees to share their thoughts, and they should also be flexible in their approach, making changes as necessary to ensure that the process is working effectively.</p><p>But in order to be able to efficiently process and utilise all those insights, you also need the ability to easily contextualize them with all the relevant information one would need to make use of them. These are a couple of things that might be useful here:</p><ul><li>Who produced this insight?</li><li>What feature is this insight related to?</li><li>How big is the problem/opportunity in your estimation?</li></ul><p>To simplify the contextualization, a predefined high-level representation of the system, with its abilities and processes, their particular value to the overall business and all the responsible stakeholders might be useful, especially if the organisation is large enough to not be fully represented in everyone’s minds.</p><p>To ensure that insights are effectively contextualized, organisations need a channel through which they can flow and a way to aggregate them by their tagged context. For example, having the ability to retrieve all insights related to a particular feature or customer satisfaction metric can provide a comprehensive overview of the state of a particular aspect of the business. This can be achieved through integration between Slack and Notion, with every insight being required to follow a custom format. The message is then automatically logged into a Notion database for future reference. This makes it easy to retrieve and analyse insights at a later time while ensuring that they are well-organized and easily accessible.</p><p>The particular ways in which this flow of data might be implemented are specific to every company, and it might differ depending on how many different functions the product has, or how regimented the departments are. What’s important is to give the company to easily capture, process and access process-based insights from its employees.</p><h3>Conclusion</h3><p>Employees are one of the most significant sources of knowledge. Their direct experience with the reality of the business can offer valuable insights into the current situation in which the business finds itself, and it can help guide it towards more effective ideas. Capturing these insights and creating a structure in which they can be fully utilised is an important part of learning, which is crucial to the process of discovering effective ideas, which in turn might be the most important thing that a start-up does.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8bb4066a0c0" width="1" height="1" alt=""><hr><p><a href="https://blog.startupstash.com/the-art-of-discovery-why-learning-is-key-to-start-up-success-f8bb4066a0c0">The Art of Discovery: Why Learning is Key For Startup Success</a> was originally published in <a href="https://blog.startupstash.com/">Startup Stash</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to stop worrying and love the code]]></title>
            <link>https://catalincarabas.medium.com/how-to-stop-worrying-and-love-the-code-9be1f6395f00?source=rss-880e6e4a22ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/9be1f6395f00</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Catalin Carabas]]></dc:creator>
            <pubDate>Mon, 12 Dec 2022 10:30:53 GMT</pubDate>
            <atom:updated>2022-12-12T10:30:53.870Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5wgZP9R13PBgA9wlJ-acow.jpeg" /></figure><p>A while back I had a shift in how I see code quality.</p><p>Before I saw code as this well-understood tool that needs to be tested in order to iron out any possible inconsistencies. Small quarks in implementation, mostly irrelevant, should be squashed more for the sake of aesthetic perfection.</p><p>But after repeated moments of sheer confusion, as code that I was 110% sure about ended up causing downtime in production, a subtle, but important change in perception occurred.</p><p>I started seeing it more as a <strong><em>“demonic machine from hell”,</em></strong> whose single terrible property consists of its ability to break at the exact point that was left untested.</p><p><strong>René Descartes</strong> came up with a similar concept, imagining that an Evil Demon of <em>“utmost power and cunning has employed all his energies in order to deceive”</em> him. The daemon would trick all his senses and judgements and build a false reality around the observer. The question <strong>Descartes</strong> was trying to answer was “what can be considered objective truth”.</p><p>What I try to answer is “does this code work properly”?</p><p>You can also think of this as some sort of quantum system of bugs, which disappear when tested.</p><p>Or some kind of Murphy’s law for software engineers: “<em>Everything that is not tested, will break.</em>”</p><p>I think you get the point…</p><p>The basic idea is that one cannot trust their own code under any circumstance.</p><p>So… then what?</p><p>Resign to a life of sleepless nights, as I worry that production can go down at any moment.</p><p>The solution might seem pretty simple: <strong>Just add more tests!</strong></p><p>Problem solved. Job done. Thank you very much.</p><p>……….</p><p>The only little, small, tiny, insignificant thing that remains is the fact that, well…</p><blockquote>HOW CAN I TELL IF THE CODE IS WELL-TESTED?</blockquote><p>I could start by trying to test all the possible inputs and make sure that they result in the expected output. But even if the function is pure, and even if it has simple parameters ( so no array of deeply nested objects ) it still quickly becomes impossible to define what “all the possible inputs” mean.</p><ul><li>For a string, you cannot test with all the possible combinations of characters, at any length.</li><li>For a date, you cannot test for any fraction of milliseconds.</li></ul><p>So there clearly have to be some informed decisions taken there. Some simplifications that would allow you to consider that the result of “2022-12-09 16:20:19.592607 +00:00” would be the same 2022-12-09 16:20:19.592608 +00:00 . But this is the exact point where you step outside of the testing guarantees and you start trusting your code again.</p><p>Testing only a <strong>relevant</strong> subset of the inputs requires a complete understanding of the code and its inflexion points, and the gaps that exist in the understanding of the code will also exist in its tests.</p><p>Back into the same ditch…</p><h3><strong>A workaround and an acceptable tradeoff?</strong></h3><p>Let&#39;s try to go about this in a different way.</p><p>When you build a bridge, you need to be extremely careful with the structures you design and the way you test those structures. A mistake could mean not only massive costs in rebuilding, but also lost lives, in case something goes wrong.</p><p>When you build a physical product ( a microwave ) you get things right from the start, else the products already sold might need to be retracted and refunded ( 10% of the total ), or the company be sued by the consumers. But the designs can change and the product line is restarted. The cost of bugs is orders of magnitude smaller.</p><p>When you ship software on floppy disks, you need to get the software right else the clients will complain, and you’ll need to ship additionally fixed, which implies a loss in customer trust and extra costs. The cost of bugs is orders of magnitude smaller again.</p><p>But what happens when the cost of change is minimal, when updates are instant and mandatory, like on a website? There still is an impact on the number of customers lost and possible bad google reviews, but there might be something to say about the role of correctness in a world where the cost of change is so small.</p><p><strong>Because correctness has a cost.</strong></p><blockquote><strong>More importantly, the cost of correctness should not be greater than the cost of the bugs it prevents.</strong></blockquote><p>Sometimes it might be cheaper to move fast, push code and fix it in production. ( Blasphemy! )</p><p>Other times, if the goal is to increase the system quality, there might be other strategies than increasing correctness:</p><h4><strong>Minimising the cost of a bug:</strong></h4><ul><li>Weighted traffic</li><li>Monitoring / Alerts</li><li>On call engineers</li></ul><h4><strong>Minimising the cost of a fix:</strong></h4><ul><li>Documentation</li><li>Fast debugging</li><li>Fast deployments</li></ul><p>There are industries and products where the cost of bugs would always be too great. Especially where these bugs can lead directly to lives being lost. So this is clearly not a generally applicable suggestion.</p><p>It is just a way of thinking about the assumptions behind our daily work, and checking, at least from time to time, that the conditions on which these assumptions are based still hold.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9be1f6395f00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The network effect of knowledge]]></title>
            <link>https://catalincarabas.medium.com/the-network-effect-of-knowledge-f3651bea330a?source=rss-880e6e4a22ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3651bea330a</guid>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[knowledge]]></category>
            <category><![CDATA[network]]></category>
            <dc:creator><![CDATA[Catalin Carabas]]></dc:creator>
            <pubDate>Sat, 17 Jul 2021 14:57:32 GMT</pubDate>
            <atom:updated>2021-07-24T02:22:08.833Z</atom:updated>
            <content:encoded><![CDATA[<p>How incremental characteristics can lead to exponential differences</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BBUKs41zUMfWLgqqCcafJw.jpeg" /><figcaption>Knowledge network</figcaption></figure><p>It is fair to say that people have incremental differences in their capacities. Some learn slightly faster than others, some have slightly better memory, etc. . But what then can explain the orders of magnitude in differences between their productivity? A savant in a certain domain might be capable of work that would take the average human decades. It can not be effort and it cannot be time, as these tend to increase linearly too.</p><blockquote>One thing that can explain this difference is the networking effect of their knowledge.</blockquote><p>But does knowledge have a network effect in the first place?</p><p>A simplified<a href="https://en.wikipedia.org/wiki/Network_effect"> definition of the network effect</a> is that values exist in the relations between the different nodes of the network, and with every new node, the number of possible links increases exponentially. Each node benefits, directly or indirectly, from the presence of the other nodes.</p><p><strong>Culture</strong> has a network effect: the more people believe it, the more plausible it becomes because more people are creating reasons to believe it. In this case, what gets amplified is the belief.</p><ul><li><strong>Religion </strong>has a network effect that is reinforcing the belief.</li><li><strong>Authority</strong> has a self-reinforcing network effect.</li><li><strong>Science </strong>also has a network effect: the more accurate the concepts already present, the more accurate future selections of concepts will be, the more accurate the result. What gets amplified is the accuracy of our representation of reality</li></ul><p><strong>Language</strong> also has a network effect: the more concepts there are, the more can be created by using those ones as building blocks. In this case, what gets amplified is the potential for new concepts.</p><p>Other networks also have this behaviour, but because they have both positive and negative effects, the result is not exponential amplification. Multiple people working on the same software will eventually lead to a non-linear decrease in productivity due to the overhead of all the coordination balancing out the advantage that each new expertise brings to the network.</p><p>So, what benefit gets amplified with each new concept added to your knowledge base?</p><p>Both the consistency of your mental representation of reality and the capacity of producing more complex throughs. Every new <em>concept</em> links to the others, increasing the network capacity in a non-linear way. Understanding knowledge this way leads to some interesting insights.</p><p>The amplification effect of each note is a function of the size, cohesion, and complexity of the network.</p><h3><strong>Size</strong></h3><p>The number of concepts that can be accessed at any given time.</p><ul><li>Integrating a new concept has a certain cost that is subtracted from your total capacity.</li><li>Concepts have a deterioration rate and maintaining them also has a cost.</li><li>Given a limited capacity, there is a finite number of concepts that can be quired and maintained at any given time.</li><li>There is a conflicting dynamic between acquiring new concepts and maintaining old ones. The more concepts you have, the more concepts you’ll have deteriorating at any given time, so the more effort you’ll spend maintaining them.</li><li>In order to grow your network, you’ll need an ever-increasing amount of effort in maintaining and acquiring new concepts. You’ll be able to grow your knowledge network as long as the cost of maintaining the existing network is smaller than your total effort capacity.</li><li>If every newly acquired concept has an exponential effect on amplifying the effects of the network, every lost concept has the same effect in the opposite direction.</li><li>The network size will plateau at an equilibrium between the learning and the deterioration rate. A temporal increase in the learning rate ( or a decrease in the deterioration rate) will result in an unsustainable network size, which will deteriorate back to the plateau level supported by the average learning rate. In the same way, a temporal decrease in the learning rate ( or a temporal increase in the deterioration rate ) will result in a more easily maintainable network that will allow for more effort spent on learning in the future.</li></ul><h3><strong>Cohesion</strong></h3><p>The ability to link concepts to other concepts.</p><ul><li>Any link between two concepts has a cost to create and to maintain</li><li>A node without any links will increase the network capacity linearly. A network with the maximum number of links will increase the network capacity exponentially</li><li>When two different concepts are given, one belonging to the same knowledge domain as the cluster and one not, it’s easier to reach a higher cohesion level with the concept belonging to the domain.</li><li>Concepts that are better linked will be easier to maintain due to the greater probability of being accessed more frequently.</li><li>Adding concepts into the existing network has a greater impact than adding detached concepts due to the exponential network effect. A new piece of information will have value not only in itself but in the links it can make with existing information, enabling more complex patterns of thought.</li></ul><h3><strong>Complexity</strong></h3><p>The ability to create substructures of multiple interlinking concepts.</p><ul><li>The reason why some concepts are harder to understand ( <em>integrate</em> ) is that it requires a larger set of underlying concepts to be learned and linked.</li><li>The greater the number of concepts linked, the more unstable the structure as a whole is due to a greater chance that any one of its underlying concepts will be lost.</li></ul><p>Given a network with two separate clusters of knowledge, the most rewarding concepts acquired are the ones that bridge the gap between them, leading to a more cohesive singular network. At the same time, the worst kind of deterioration can impact the nodes between clusters, resulting in a non-linear decrease amplified by the number of nodes in the separating cluster. But is not clear if knowledge clusters can exist completely detached from one another.</p><h3>Why is this important?</h3><p>It’s easy to look at experts, even in our own field, and be amazed and discouraged by their ability and knowledge. We know how hard it was to reach our current level, so it must be 10 times as hard to be 10 times as efficient. But we forget that even our own development was not linear, and, more importantly, we also fail to predict that the same non-linearity will hold in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3651bea330a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is value?]]></title>
            <link>https://catalincarabas.medium.com/what-is-value-4a64d1bd7f4c?source=rss-880e6e4a22ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a64d1bd7f4c</guid>
            <category><![CDATA[investing]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[stocks]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[stock-market]]></category>
            <dc:creator><![CDATA[Catalin Carabas]]></dc:creator>
            <pubDate>Mon, 03 May 2021 14:53:28 GMT</pubDate>
            <atom:updated>2021-05-04T10:04:29.084Z</atom:updated>
            <content:encoded><![CDATA[<p>Thoughts on the current economic situation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nijJ8SVZhoMxg42-Gn7wSw.png" /></figure><p>Given our current economic climate, the explosion in <a href="https://finance.yahoo.com/quote/%5EGSPC/chart?p=%5EGSPC#eyJpbnRlcnZhbCI6IndlZWsiLCJwZXJpb2RpY2l0eSI6MSwidGltZVVuaXQiOm51bGwsImNhbmRsZVdpZHRoIjo0LjM4NDYxNTM4NDYxNTM4NSwiZmxpcHBlZCI6ZmFsc2UsInZvbHVtZVVuZGVybGF5Ijp0cnVlLCJhZGoiOnRydWUsImNyb3NzaGFpciI6dHJ1ZSwiY2hhcnRUeXBlIjoibGluZSIsImV4dGVuZGVkIjpmYWxzZSwibWFya2V0U2Vzc2lvbnMiOnt9LCJhZ2dyZWdhdGlvblR5cGUiOiJvaGxjIiwiY2hhcnRTY2FsZSI6ImxpbmVhciIsInBhbmVscyI6eyJjaGFydCI6eyJwZXJjZW50IjoxLCJkaXNwbGF5IjoiXkdTUEMiLCJjaGFydE5hbWUiOiJjaGFydCIsImluZGV4IjowLCJ5QXhpcyI6eyJuYW1lIjoiY2hhcnQiLCJwb3NpdGlvbiI6bnVsbH0sInlheGlzTEhTIjpbXSwieWF4aXNSSFMiOlsiY2hhcnQiLCLigIx2b2wgdW5kcuKAjCJdfX0sInNldFNwYW4iOnsibXVsdGlwbGllciI6NSwiYmFzZSI6InllYXIiLCJwZXJpb2RpY2l0eSI6eyJwZXJpb2QiOjEsImludGVydmFsIjoid2VlayJ9LCJtYWludGFpblBlcmlvZGljaXR5Ijp0cnVlLCJmb3JjZUxvYWQiOnRydWV9LCJsaW5lV2lkdGgiOjIsInN0cmlwZWRCYWNrZ3JvdW5kIjp0cnVlLCJldmVudHMiOnRydWUsImNvbG9yIjoiIzAwODFmMiIsInN0cmlwZWRCYWNrZ3JvdWQiOnRydWUsImV2ZW50TWFwIjp7ImNvcnBvcmF0ZSI6eyJkaXZzIjp0cnVlLCJzcGxpdHMiOnRydWV9LCJzaWdEZXYiOnt9fSwiY3VzdG9tUmFuZ2UiOm51bGwsInN5bWJvbHMiOlt7InN5bWJvbCI6Il5HU1BDIiwic3ltYm9sT2JqZWN0Ijp7InN5bWJvbCI6Il5HU1BDIiwicXVvdGVUeXBlIjoiSU5ERVgiLCJleGNoYW5nZVRpbWVab25lIjoiQW1lcmljYS9OZXdfWW9yayJ9LCJwZXJpb2RpY2l0eSI6MSwiaW50ZXJ2YWwiOiJ3ZWVrIiwidGltZVVuaXQiOm51bGwsInNldFNwYW4iOnsibXVsdGlwbGllciI6NSwiYmFzZSI6InllYXIiLCJwZXJpb2RpY2l0eSI6eyJwZXJpb2QiOjEsImludGVydmFsIjoid2VlayJ9LCJtYWludGFpblBlcmlvZGljaXR5Ijp0cnVlLCJmb3JjZUxvYWQiOnRydWV9fV0sInN0dWRpZXMiOnsi4oCMdm9sIHVuZHLigIwiOnsidHlwZSI6InZvbCB1bmRyIiwiaW5wdXRzIjp7ImlkIjoi4oCMdm9sIHVuZHLigIwiLCJkaXNwbGF5Ijoi4oCMdm9sIHVuZHLigIwifSwib3V0cHV0cyI6eyJVcCBWb2x1bWUiOiIjMDBiMDYxIiwiRG93biBWb2x1bWUiOiIjZmYzMzNhIn0sInBhbmVsIjoiY2hhcnQiLCJwYXJhbWV0ZXJzIjp7IndpZHRoRmFjdG9yIjowLjQ1LCJjaGFydE5hbWUiOiJjaGFydCIsInBhbmVsTmFtZSI6ImNoYXJ0In19fX0-">stock prices</a>, <a href="https://coinmarketcap.com/currencies/bitcoin/">cryptocurrencies</a>, <a href="https://www.forbes.com/sites/youngjoseph/2021/03/29/nft-market-rages-on-nfts-market-cap-grow-1785-in-2021-as-demand-explodes/?sh=225bb95d7fdc">NFT</a>, and whatnot, I’ve been thinking and discussing a lot about value and what makes something a certain price.</p><h3>What makes something valuable</h3><p>There are two fundamentally different aspects that can give value to an asset.</p><p>One makes money directly, like loans, rents, and dividends, and in a certain statistical sense, insurance. This aspect cares about the future only when it comes to the ability of the underlying asset to continue producing value. You can predict its performance given a good enough understanding of the system in which it operates. The risk comes from our inability to <strong>completely</strong> predict its evolution, as there could always be <a href="https://www.investopedia.com/terms/b/blackswan.asp">black swan</a> events that completely disturb the conditions of the system.</p><p>Then there is the second one, which makes money when sold for a higher price than the one for which it was bought. The higher price could be linked to an increase in the ability of the underlying asset to produce more value in the future than it is today, but, and this is key,<strong> it doesn’t have to be</strong>.</p><blockquote>The only thing that is required is the belief that someone else will buy it for a <a href="https://www.investopedia.com/terms/g/greaterfooltheory.asp">higher price</a>.</blockquote><p>The problem here is that predicting the performance of this asset requires predicting what others will predict about its performance. Their predictions, in turn, will need to include yours, and so forth, ad infinitum. This is what is called <strong>second-order chaos</strong>, something that not only leads to vastly different outcomes starting from infinitely small differences in starting conditions, but that also responds recurrently to predictions about its own outcome.</p><blockquote>This is how bubbles are formed. Investors are buying assets on the belief that they will be able to sell them latter for a higher price, up to the point when no one wants to buy them anymore. They are left then holding assets that are unable to justify their price solely by their ability to directly produce value. The asset has then to be sold for less. In the case of prolonged specualtion, the final value will be just a fraction of the peak price. ( Buying obscure art on the belief that will apreciate in value is a good example, as that art cannot produce no other value if no want want to buy it. )</blockquote><p>We’ve seen the<a href="https://coinmarketcap.com/currencies/bitcoin/"> incredible return rate</a> of some assets in the recent past, but how does one go about assessing the risk of these things? The first question to ask is, what type of aspect drives this growth? Is it the underlying <strong>value-producing ability</strong> of the asset, or is it just the expectation of <strong>price appreciation</strong>? Do you, or anyone you know, bought this because of its intrinsic ability to generate and return value, or did you buy it just so that you can sell it later for a higher price, always waiting and anticipating the moment when the momentum stops so that you can sell? How many people do you think are buying just to sell at a higher price?</p><p>These are the types of questions that will indicate how much of the asset price is inflated by speculation. There could be complex justifications thrown around, and the hype could be coincidentally justified by the future development of the asset, but this not change the fact that its current value, based on the actions of those that bought it, is driven by the expectation of price appreciation rather than the production of future value.</p><h3>A simple case study</h3><p>The situation is complicated even more by the fact that most assets have both aspects present in their value evaluation at any time, so assessing the relative impact of each one is an impossibly hard task.</p><p>Let’s simplify the problem, A LOT, to just a number of variables and do a thought experiment with Microsoft, a well-performing company with a healthy balance sheet and dividends, to illustrate the point.</p><p>With a market cap of 1.9 trillion and a <a href="https://www.investopedia.com/terms/p/price-earningsratio.asp">P/E ratio</a> of 34, it’s hard to say how much money has gone into its evaluation solely on the expectation that it can be sold later at a higher price.</p><p>The most Microsoft could pay out in dividends with its current structure and price and in a sustainable way is about 3%. An investment in a single company is risky, so for it to make sense it should surpass the market average return, between 7% and 10%, by a considerable margin, so let’s say it should return between 11% and 14%.</p><p>In order for the profits of the company, so the maximum dividend pay, to be competitive with the market returns, the company has to increase its earnings 4 times faster than its evaluation <strong>before it runs out of potential space to grow. </strong>This last bit is essential and is what fuels the speculation. We don’t know the ways in which a company can reinvent itself and keep growing. It might even be able to keep growing for the foreseeable future of our species and grow to dominate all aspects of human life*.</p><p><em>*Quick absurd detour. There is a cap to all the growth after all. The world GDP is about 90 trillion and it is increasing at about 3.2 percent per year. If Microsoft keeps increasing at 20% per year, it will eventually, inevitably, catch up with the world GDP in about 24 years. At that point, it could be considered that it has reached a point of complete economic dominance.</em></p><p>But, embedded in that 34 times earning evaluation, is the assumption that Microsoft profits will at least quadruple and sustain competitive dividend returns. With a 15% increase per year, that will take about 10 years to happen. If at any time in the next 10 years the company evaluation is raised, then the goalpost moves, and the duration to sustainability has to be extended.</p><p>So, when you are buying Microsoft shares, are you doing it because you expect the profits of the company to quadruple in the next 10 years?</p><p>Do you believe its growth rate is sustainable?</p><p>Do you believe that once the earnings increase, so will the price of the stock and you will be able to sell higher?</p><p>Do you want the share price to increase?</p><p>Given that <a href="https://www.businessinsider.com/personal-finance/investment-pros-cant-beat-the-stock-market-2020-7?r=US&amp;IR=T">nearly 90% of actively managed investment funds failed to beat the market over the last 15 years</a>, the rise in retail investors, and the predisposition of bubbles to form and pop on a regular basis, we can assume there are at least some investment bases solely on the expectation of higher evaluations. How much is it? If history is any indication, once the price settles and the expectation of growth dissipates, we are left with at least half the peak price. So, are we at peak price? Probably not, as the evaluation before the 2001 tech bubble were between 70 and 80 times higher than the earning, while today are around half that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXwXVy40SWGXH673JmyX8Q.png" /></figure><p>It doesn’t matter that in 10 years’ time the current evaluation will be fully justified. A lot of things can change and go wrong in 10 years.</p><h3>No handlebars</h3><p>Earnings are what indicates to us if our estimated value can be justified.</p><p>A big reason why the 2001 bubble was so massive was that the expectation of profits was removed from the equation of estimating the prices. History has proved that the internet industry was many times more profitable than even the wildest estimations, but at that point in time, for the average investor, it would have been impossible to correctly estimate the future on such a large scale. Sometimes these predictions just don’t pan out.</p><p>The 2008 financial crash has thought us what happens when there is an expectation that an asset class can’t go down. People will leverage the investment to amplify their profits on the promise that money can’t be lost. And when money is lost, because of all that leverage, the loss is so much greater. The fact that it happened to an asset class as stable as housing, the fact the no one saw that one coming, or at least that even if some have seen it coming they have still participated in it on the promise of greater returns, tells us that not even the biggest, most visible and trusted sectors of our economy are save from this type of phenomenon.</p><p>So, finally, what about cryptocurrencies? What about NFTs? What about multibillion-dollar companies that have yet to show a profit? How can we make sense of the general appreciation in prices seen since the start of the year?</p><h4>NFTs</h4><p>All NFTs have based on the premise that scarcity makes something valuable. This has been pointed out by economics long ago.</p><blockquote>Scarcity, however, is just a multiplier of value.</blockquote><p>Just try to sell that unique drawing of a dinosaur that your child has made. In order for an NFT to have value, the underlying creation that is represented by the token also has to have value. The original creation can be stored solely on the blockchain, giving it the status of the original creation, but this still relies on the fact that there is an infinite appetite for creative work. Given the fact the global art market was “only” 67 billion dollars in 2018, we see that there clearly is a limit for how much people are willing to spend on this kind of luxury. And the art market, as well known as it is for being an alternative investment vehicle for people, is still anchored in a meaningful way with creations people hold to be valuable outside of investment, like religious paintings and works of art of historical importance.</p><p>If estimating even something as transparent as Microsoft, with its public earning and 30+ plus of history, quickly becomes impossible due to our inability to separate the expectation of price appreciation from the expectation on increasing value, what can we tell about something as opaque as the blockchain? Or digital pixelated avatars on an obscure website that hold the promise of being unique in their respective network? Is scarcity what people really value, or is it all just the expectation of future returns?</p><p>There is no way to tell. As the internet did 20 years ago, it could prove to be the new best thing. Or not. I am skeptical of anyone why says that they can anticipate the future of our world in any way. And even if history will prove some right and others wrong, there is simply no way to tell which is which right now.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a64d1bd7f4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Host an SSR React website and API backend on AWS for less than 20$ a month.]]></title>
            <link>https://catalincarabas.medium.com/host-an-ssr-react-website-and-api-backend-on-aws-for-less-than-20-a-month-dad24c4041f7?source=rss-880e6e4a22ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/dad24c4041f7</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Catalin Carabas]]></dc:creator>
            <pubDate>Fri, 17 Apr 2020 07:55:53 GMT</pubDate>
            <atom:updated>2020-04-17T07:55:53.601Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction:</h3><p>Three-tier architecture for less than $20 a month, with a smooth development process, easy versioned deployments and a 90+ score on <a href="https://developers.google.com/speed/pagespeed/insights/">Google Page Speed</a>.</p><h3>But why?</h3><ul><li>Low cost</li><li>Minimal set-up</li><li>Minimal maintenance</li><li>Easy deployment and versioning</li></ul><p>Let’s say you have a personal project, like a <a href="https://cinpick.com/">movie discovery website</a>, done not as a business, but as a hobby. Naturally, you would like to open it up to the public, but not if this means hundreds of dollars spent each month in database and server instances, so things have to be <strong>cheap</strong>. You also don’t want to compromise on the development/deployment process, nor on the user experience, so things have to be <strong>fast</strong>. What do you do?</p><p>As you ponder that question, let me tell the story of what I did.</p><h3>Table of Contents</h3><p>–<a href="#e9a7"> <strong>Section 1 — The stack</strong></a><br> — <a href="#624b">SSR React + Redux </a><br> — <a href="#0e5e">Quick and easy Github actions deployments</a> <br> — <a href="#f429">ECS Host </a><br> — <a href="#b878">Distribution</a><br>– <a href="#aa14"><strong>Section 2 — The Results</strong></a><br> — <a href="#adb4">Google Speed </a><br> — <a href="#4b3e">Monthly Cost</a><br>– <a href="#17f5"><strong>Section 3 — Further Improvements</strong></a><br> — <a href="#400f">Load balanced, multi-AZ, ECS-Fargate</a><br> — <a href="#6f4f">Autoscaling</a><br> — <a href="#5a4d">Terraform all the way down</a></p><h3>Section 1 — The stack</h3><ul><li>SSR React + Redux for the <em>client</em></li><li>Github actions for <em>deployment</em>.</li><li>ECS — EC2 for the <em>host</em></li><li>CloudFront +Routes 53 for <em>distribution</em></li><li>Dynamo + Lambda + API Gateway for the <em>API</em></li></ul><h3>SSR React + Redux</h3><ul><li>New nextJs app</li><li>React app / redux</li><li>Configure Github Actions</li></ul><p>I have chosen React for the front-end, as it offers the most pleasant developer experience (worked on Angular, Angular4, HandleBars, jQuery, etc. ), and went with NextJs for those sweet sweet SSR advantages ( Speed and SEO being the main ones ). You can create your own local NextJs app by running “<a href="https://nextjs.org/docs">npm init next-app</a>“. Once you get that going, you can more or less develop your app in the same way you would do a SPA. The main difference is the way <strong>Routing</strong> is handled.</p><p><strong><em>/* Quick aside on NextJs Routing */</em></strong></p><p><em>Next has its own convention of transforming the files in the “</em><strong><em>pages</em></strong><em>” folder in actual routes, so for example if in your pages folder you have a “similar.js” file, then going to </em><a href="https://cinpick.com/similar"><em>/similar</em></a><em> will result in the content of that file. Handling dynamic params in the URL is done by having subfolders with the param name as the file name in between square brackets, so </em><strong><em>movie/[id].js</em></strong><em> results in </em><a href="https://cinpick.com/movie/360"><em>https://cinpick.com/movie/360</em></a><em>. Cool ;). This, of course, can be overwritten with your own </em><a href="https://nextjs.org/docs/advanced-features/custom-server"><em>express server</em></a><em>, in case you need to do fancier logic before rendering the page.</em></p><p><em>When you import a link from “next/link” you basically tell next to download only the JS files from the page you want to navigate to and update the DOM. This way your current state ( think Redux ) doesn’t need to be reinitialized on every page navigation. Navigating to dynamic URL is done by specifying the “as” property on the link:</em></p><p><em>&lt;Link href={“/movie/[id]”} as={`/movie/${item.id}`}</em></p><p><strong><em>/* Routing aside ended */</em></strong></p><p>Another useful thing to know is that you can have control over the “document.html” file that gets rendered and download first by the browser by creating a <a href="https://nextjs.org/docs/advanced-features/custom-document">_document.js</a> file in your pages folder. You can customize different aspects of the document in there ( <a href="https://medium.com/javascript-in-plain-english/ssr-with-next-js-styled-components-and-material-ui-b1e88ac11dfa">like server-side rendering the styles</a> )</p><p>Now that you are done with the SSR set-up, you can proceed to the actual React app and state management. Here is a really nice <a href="https://jibin.tech/nextjs+redux/">article</a> for setting up the Redux store to work between pages. As you can see, the Provider is implemented in another one of Nextjs’s overwriting pages called _app.js. This is at an intermediary level between the document and the content, and it’s the place where you can initialize other libraries ( like google analytics, google tag manager, etc. )</p><h3>Quick and easy Github actions deployments</h3><p>Now that you have a working local website, you need to get it running somewhere online. This will be done in two parts: Building a docker image and pushing it to <strong>ECR</strong> ( AWS’s image repository ) and running that image in <strong>ECS</strong> ( AWS’s Docker container service ). Don’t be discouraged if you haven’t worked with docker or ECS before, the whole process consists mainly of writing some config files and doing some set-up on AWS, won’t take longer then an hour ;). ( it’s crazy, I know…)</p><p>First, create your GitHub repository, and navigate to it’s “Actions” Tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-MRiXiey0qPY0kKHNmIWpA.png" /></figure><p>There you can choose between multiple action templates, one of which is exactly what we need. So search and choose the one that says “Deploy to Amazon ECS”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sJMaIlsrAvn3uv-9JJNDrA.png" /></figure><p>Then you’ll be greeted by the aws.yml document, which currently has 5 steps:</p><p>1. checkout</p><p>2.configure was credentials</p><p>3. login to ECR, build/push the image</p><p>4.create task definition</p><p>5. deploy task definition</p><p>The way I did this, is to remove the last two steps ( you’ll see later why ), and just configure the first three ones. This will result in a new docker image being pushed to your ECR repository.</p><p>For faster deployment I’ve changed the “<strong>on: release: types: [created]</strong>” bit from the beginning of the file to “<strong>on: push: branches- master</strong>”. This will create a new image every time you push to master, but because we’ve commented out the deployment steps ( last 2 steps ), we won’t have any issue with our app updating when it shouldn&#39;t.</p><p>The next thing you’ll need to this configuration is adding your <a href="https://aws.amazon.com/blogs/security/wheres-my-secret-access-key/">AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY</a> as secrets to your Github repo. Don’t worry, their values will be encrypted and no one will have access to them there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M5VX06JbDyDbVcId0bh8YA.png" /></figure><p>The second thing is creating a repository on ECR, so go ahead and create one and then copy its name and add it to ECR_REPOSITORY in the build-image step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sGfizBupfoiwsSiyLPenvA.png" /></figure><p>And the last thing you need is to create a file called Dockerfile in your project folder and to add <a href="https://medium.com/@khwsc1/a-simple-react-next-js-app-development-on-docker-6f0bd3f78c2c">these</a> to it.</p><pre>FROM node:12</pre><pre>WORKDIR /usr/src/app</pre><pre>COPY package*.json ./<br>RUN npm install</pre><pre>COPY . .</pre><pre>RUN npm run build</pre><pre>CMD [ “npm”, “start” ]</pre><p>In case you used an express server to handle you routing, replace the last line with you actually server starting command (EX: CMD [ “npm”, “run”, “prod_start” ] )</p><p>And we should be done with this part. Try pushing your code to master and watch the magic happen. You should now have a new image in your ECR repository, so let’s proceed to the second part.</p><h3>ECS Host</h3><ul><li>Create cluster + service + task definition</li><li>Create Cloudfront distribution with the IP of the instance</li><li>Explain how to deploy</li></ul><p>In order to run your image on AWS, you’ll need to configure 3 things: a Cluster, a Service, and a Task Definition. Let’s get started with the cluster.</p><p><strong><em>/* Quick aside on ECS */</em></strong></p><p><em>You can think about the Cluster &gt; Service &gt; Task definition like this:</em></p><ul><li><strong><em>The</em></strong><em> </em><strong><em>task definition </em></strong><em>is made of specific instructions about your app ( what port is using, how it should be accessed, how much CPU/memory it needs and so on ). When your app gets updated, you’ll also need to create a new version for your task definition.</em></li><li><strong><em>The service</em></strong><em> is responsible for routing, running, restarting and scaling the multiple “tasks” of the same definition.</em></li><li><strong><em>The cluster</em></strong><em> is responsible for running the services. The best thing about Docker is that you can run a lot of different services (apps) on the same instance without interference.</em></li></ul><p><strong><em>/* ECS aside ended*/</em></strong></p><p>Navigate to <em>ECS &gt; clusters</em> and choose “Create a cluster”. Give it a name, modify the instance type to be a t2 micro ( <a href="https://aws.amazon.com/ec2/instance-types/t2/">this is one of the cheaper ones</a> ) and press confirm. <strong>Cluster</strong> ✅.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pc6qoLyBPgaYyDa8agz_vg.png" /></figure><p>Once that is created <em>navigate to ECS &gt; Task Definitions</em> and create a new one. Choose its type as EC2 and press next, give it a name, add a role, set 256 for both <strong>Task memory (MiB) </strong>and <strong>Task CPU (unit) </strong>and then press “Add container”. Once the container panel opens, add a name, paste in the docker image URI ( copy it from the ECR repository ), set a hard limit of 250, and add the pot mappings 80 ( host post ), 3000 ( container port ) as TCP (protocol), and 250 for Environment &gt; CPU units and then press “Add”. Scroll to the bottom and press “Create”. <strong>Task definition</strong> ✅.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZMvSUtZgeF35P_hMIT_IKg.png" /></figure><p>Navigate to your ECS cluster &gt; Service tab and press “Create”. Choose EC2 type, choose the latest version of your task definition, give a name to the service, choose 1 for <em>Number of tasks, </em>set <strong>Minimum healthy percent to 0 and Maximum percent to 100, </strong>and press next until the Service is created. <strong>Service</strong> ✅</p><p><strong><em>/* Quick aside on ECS */</em></strong></p><p><em>Why are we setting the </em><strong><em>Minimum healthy percent</em></strong><em> to 0? Well, what this will do is to shut down our old version before running the new one. This means that for a couple of seconds at each update, our service will be down. Unfortunately, if the old version is still running when the new one starts, then it means the port using by the old one is occupied, so the new one won’t be able to start. By setting it to 0 first we make sure that the old one is not running anymore. I’ve also added a bit about deployments with no downtime in the “Further improvements” section at the bottom, in case you need it.</em></p><p><strong><em>/* ECS aside ended*/</em></strong></p><p>You know that everything is running when you’ll see this in your service: service “your service name” has reached a steady state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nRB16bJYNVpkz0wOYWci4g.png" /></figure><p>You can get the IP address of your running instance if you go to ECS &gt; you cluster &gt; your service &gt; tasks tab &gt; click on task &gt; expand the container &gt; external Link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QOmH0vP2L0v2g-YREWSLbA.png" /></figure><p>So you’re done with all the set-up, now you have your site running online ;). But that IP is not not looking that good, is it? We need to do two more things if want to put it behind a nice domain: create a CloudFront distribution for that IP and point Route 53 to it.</p><h3>Distribution</h3><p><a href="https://aws.amazon.com/cloudfront/">Cloudfront</a> is mainly responsible for caching your content. Once this gets configured correctly, you’ll start seeing the Response Header <strong>x-cache: Hit from CloudFront. </strong>This means that the request is no longer going to the origin ( your server ) but it’s instead served from the Cloudfront cache, which will speed things up dramatically.</p><p>Navigate to CloudFront and click “Create Distribution”</p><ul><li>choose web distribution</li><li>for Origin Domain Name past the Public DNS of your running instance ( you can get this from<em> ECS &gt; you cluster &gt; your service &gt; tasks tab&gt; click on task &gt; Click on EC2 instance id &gt; Description &gt; Public DNS (IPv4)</em></li><li>select Yes for <strong>Compress Objects Automatically</strong></li><li>Click “Create”.</li></ul><p>You’ll need to wait about 15 minutes until the distribution is created, but once that is done you’ll be able to see your site at the URL found in the <em>distribution &gt; General tab &gt; Domain Name</em>. ( should be something like xxxxxx.cloudfront.net )</p><p>The last thing we need to do with the CloudFront distribution is to reference it from <a href="https://aws.amazon.com/route53/">Route 53</a>, but in order to do that, a couple of things need to happen first. We need to:</p><ol><li><a href="https://medium.com/@connorleech/purchase-and-set-up-a-new-com-domain-name-using-aws-route-53-7aefdb082055">Register a domain</a></li><li><a href="https://medium.com/@hebaabdelrehem/how-to-request-ssl-certificate-on-aws-amazon-certificate-manager-d695fbc045cb">Request an SSL certificate</a></li><li>Update our CName on the CloudFront distribution to include the domain and add your SSL certificate</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OsMxS5IfOT2WdLEtZBUvuA.png" /></figure><p>4. Create a new Hosted Zone in Route 53 for your domain</p><p>5. Create a new Record Set in your Hosted Zone.</p><ul><li>Leave black name for the root domain ( <a href="https://cinpick.com/">https://cinpick.com</a> )</li><li>choose type A IPv4 Address</li><li>Add your cloud front-distribution ( this needs to match the CName in the cloud font distribution, so if that one had www, the name of this record also needs yo have www )</li></ul><p>6. Wait a few minutes and try your domain! :)</p><p>At this point in time, you should have a <em>fast</em> and <em>cheap</em> infrastructure for your hosting your site. Now let’s go a bit through how you can update the existing docker image. Once you’ve to push again to master, Github will build and push another image into ECR.</p><p>In order to un that image, you need to go to ECS &gt; your cluster &gt; your service &gt; your task definition &gt; Click “Create new Revision” &gt; click on the container name ( not on the “Add container” button ) &gt; paste the URI of the new image &gt; click “Update” &gt; click “Create”. This will give you a task definition with the new image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SV2GaZdHlZ0tXJ3iA4N3bg.png" /></figure><p>Then go to ECS &gt; your cluster &gt; your service &gt; click “Update” &gt; change the revision to be the latest &gt; press next until service is complete. Once the events are reaching a “steady state” again, your service is updated.</p><p>If you are using CloudFront, it means that the old content is still cached, so you’ll need to run a cache invalidation. You can do that from CloudFront &gt; your distribution &gt; invalidation tab &gt; create invalidation &gt; write /* &gt; click invalidate.</p><p>That is all, your site is updated. :)</p><p>So as a recap: <em>you push to GitHub, update the task definition with the new image, update the service with the new task definition, invalidate the cache. </em>The whole thing takes about 5 mins once you get used to it.</p><h3>Section 2 — The Results</h3><h4><strong>Google Speed</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bIf443_wbEmuPFmHI8h3_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Le0cGC6qPsNhM3l2FVJIQ.png" /></figure><h4><strong>Monthly Cost</strong></h4><ul><li>t2 micro $9.50</li><li>Route53 hosted zone $0.50</li><li>Domain name $1 or 2$ a month</li><li>AWS Tax (about 10%) $1</li></ul><p>So a total of about $15. If you get an SSL certificate or a fancier domain, you might reach $20 per month.</p><h3>Section 3 — Further Improvements</h3><h4><strong>Load balanced, multi-AZ, ECS-Fargate</strong></h4><p>The biggest improvement I can think of, and the reason why I wouldn’t recommend this specific architecture for business purposes is that it’s not very resilient. It has only one running task and that means it’s <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html">single AZ</a>, so if that zone goes down, your service will also stop. This can be easily fixed by setting up multiple running tasks and load balance between them. This will also give you the opportunity to reference the load balancer in the Cloudfront distribution, so in case the closer instance goes down and it’s IP changed, you won’t have to update the distribution.</p><p>Adding a load balancer can also fix the downtime issue. When mapping the port of the app to the point of the container, we’ve chosen 80-3000-TCP, but if you had left the host port and 0 ( or blank ) then ECS would’ve assign it a random free port, so the starting task wouldn’t have had the port conflict anymore.</p><p>The reason why I didn’t choose to go with a multi az, load-balanced architecture is that another instance would add about 9$ to the bill, and the load-balancer would add about $6 more, but if think having a highly resilient and always available service is worth the price of $15, I don’t blame you. ;)</p><h4><strong>Autoscaling</strong></h4><p>The second would be to set up and auto-scaling policy, in case your project goes viral overnight and you want to keep up with the demand.</p><h4><strong>Terraform all the way down</strong></h4><p>The third recommendation, and a personal goal of mine, is to <a href="https://www.terraform.io/">terraform</a> the whole thing. Terraform is a way of maintaining your infrastructure configuration as code, so instead of you going in manually and changing names in forms and toggling buttons, you would have some configurations files where you can specify your entire infrastructure. There are a lot of advantages that come with Terraform, version controlling the configuration files among them. The other big advantage that gets thrown around is the ability to change your provide ( think AWS vs Microsoft Azure ) more easily, but in the case of personal projects, this happens quite rarely.</p><p>And that’s it for hosting the site, hope you’ve enjoyed it so far. :)</p><p>What if I want to spice things up with a couple of API, I hear you ask? And what if I want to start persisting some data? In the next part, I’ll write about how you can have a complete API backend + Db for FREE!</p><p>Sneak peek into part 2:</p><ul><li>Create DynamoDb table</li><li>Create Lambda</li><li>Create ApiGateway and link Lambda</li><li>Add Github actions file</li><li>Zip and upload zip to s3</li><li>Push to Github and update lambda</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dad24c4041f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>