<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: George Stefanis</title>
    <description>The latest articles on DEV Community by George Stefanis (@stefanisg).</description>
    <link>https://dev.to/stefanisg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F50743%2F62aca3ca-ed8e-475c-9fa3-f1fbeff11a81.jpg</url>
      <title>DEV Community: George Stefanis</title>
      <link>https://dev.to/stefanisg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stefanisg"/>
    <language>en</language>
    <item>
      <title>Completing a side project. Presenting AVCUD.</title>
      <dc:creator>George Stefanis</dc:creator>
      <pubDate>Sat, 08 Aug 2020 13:24:36 +0000</pubDate>
      <link>https://dev.to/stefanisg/completing-a-side-project-presenting-avcud-1f1k</link>
      <guid>https://dev.to/stefanisg/completing-a-side-project-presenting-avcud-1f1k</guid>
      <description>&lt;p&gt;During the lockdown I needed a way to distract myself. I decided to watch a movie but the problem I'm having is that I get paralysis from all the options. I normally end up scrolling through endless amounts of movies and in the end I don't pick anything. I decided this time to watch the best movie for each year from the year I was born until 2019.&lt;/p&gt;

&lt;p&gt;There is one problem though. How do you define "the best" movie? Is it the box office income? Is it the IMDB score? Is it the most Oscars? I decided to do what every normal person would. I did create a weighted function that takes all three into account, creates a score and ranks them by it. On the back of that I did create &lt;a href="https://avcud.com"&gt;https://avcud.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The idea is simple, you put a year in the search box and the app goes through all the data I mentioned above, crunches the numbers and gives you a visual list of the movies starting from the highest ranked. Under each movie it gives you some basic info (box office income, IMDB score, Oscars won/Oscars nominated). Clicking on the movie title gets you to the movie page where you can see more info and even get suggestions on other similar movies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--52iTtsTh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j230qe8u2gdszox1p2f8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--52iTtsTh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j230qe8u2gdszox1p2f8.png" alt="AVCUD result page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am really proud of this. It's the first time I can safely say i did deliver on a product idea I had. It does solve my problem exactly and I ended up using it all the time. I hope you like it. Next steps include creating a page to see individual actor profiles (I like searching movies by actors/directors) and curated lists of movies. I also have some technical issues I need to solve.&lt;/p&gt;

&lt;p&gt;As far as technologies are concerned the backend is written in Python3 and dockerized. The frontend is written in Svelte and server side rendered with Sapper (really enjoyed using Svelte). The site is hosted in Google Cloud and Firebase. My technical problems are concerned with Google Cloud. That will be a future blog post.&lt;/p&gt;

&lt;p&gt;If you have any feedback please let me know. Check it here: &lt;a href="https://avcud.com/"&gt;https://avcud.com/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>webdev</category>
      <category>svelte</category>
    </item>
    <item>
      <title>How do you debug?</title>
      <dc:creator>George Stefanis</dc:creator>
      <pubDate>Wed, 05 Sep 2018 12:21:15 +0000</pubDate>
      <link>https://dev.to/stefanisg/how-do-you-debug-49b4</link>
      <guid>https://dev.to/stefanisg/how-do-you-debug-49b4</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BjzzQmYA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgs.xkcd.com/comics/debugging.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BjzzQmYA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgs.xkcd.com/comics/debugging.png" alt="Debugging"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have observed 2 broad categories of debugging issues in code bases.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;The physicist.&lt;/em&gt; This type of person really carefully reads the code. Doesn't touch anything, doesn't log much. Just reads and tries to make a mental model of what's going on. They will only change code, or step through the code/add breakpoints when they are pretty sure what's wrong.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;The electrician.&lt;/em&gt; This type of person likes to probe things. Like an electrician with an electrical tester they comment things, log results and build understanding through experimentation. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first group seems to me more analytical and organized in a way. The second group is more intuitive and adventurous in their testing.&lt;/p&gt;

&lt;p&gt;Have you observed similar things? How do you approach debugging?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Understanding microservices 101. A frontend developers view.</title>
      <dc:creator>George Stefanis</dc:creator>
      <pubDate>Thu, 16 Aug 2018 10:49:23 +0000</pubDate>
      <link>https://dev.to/stefanisg/understanding-microservices-101-a-frontend-developers-view-7do</link>
      <guid>https://dev.to/stefanisg/understanding-microservices-101-a-frontend-developers-view-7do</guid>
      <description>&lt;p&gt;I've been working predominately with the frontend for more than 10 years now. While i've been contributing to different services and backends, I never spend the time to see how microservices tie together. How does it all doesn't fall apart?&lt;/p&gt;

&lt;p&gt;To me this is what a backend looks like. An app that has some API endpoints defined and returns a JSON object. But the problem is that this is how the world was 10 years ago. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9cqlag4sm1ucw818l4y4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9cqlag4sm1ucw818l4y4.png" alt="How I imagine a backend"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I had to look closer and find out how that old image i have in my head translates to todays golden standard. Microservices. I broke it down to 4 sections.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 1
&lt;/h3&gt;

&lt;p&gt;This bit is easy. This is the micro service itself. You take all that code and you move it to its own repo. Easy. Use the framework of your choice.&lt;/p&gt;

&lt;p&gt;So doing that we should end up with two services, User service and Transfer service.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 2
&lt;/h3&gt;

&lt;p&gt;OK. This is now a bit complicated. Where should this annotation live? Inside the micro service? Outside? If outside where? How would the system know where is what?&lt;/p&gt;

&lt;p&gt;We need something that knows how to translate a url to a meaningful route and talk with the right service. Kinda like a traffic controller.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;We need a gateway&lt;/em&gt;. This is one server that works as a single entry point to the system. This is basically the facade design pattern. Netflix has an open source project for that called &lt;a href="https://github.com/Netflix/zuul" rel="noopener noreferrer"&gt;Zuul&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Cool, solved it! Nope. How does the gateway know where the server is? It needs an IP! Yeah but what happens if the IP changes? Someone needs to let it know.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;We need a discovery service&lt;/em&gt;. Blame the cloud, not me. If this was 10 years ago we would have hardwired locations. Now we need a service registry though. A service registry is basically  a database of services, their instances and their locations. You call it, you ask where service A is, it tells you. Simples! &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are various tools for that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Netflix Eureka (TW uses that)&lt;/li&gt;
&lt;li&gt;Apache zookeeper&lt;/li&gt;
&lt;li&gt;Consul (We use that too)&lt;/li&gt;
&lt;li&gt;Etcd&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OK! We are done. Almost…&lt;/p&gt;

&lt;p&gt;How do you deal with failures? What do you return when one service fails? Worst, what happens when a service doesn’t fail but it keeps running?&lt;/p&gt;

&lt;p&gt;In the old days of monoliths you should have implemented a timeout. You still need to, but that alone isn’t enough. A useful pattern is that of a circuit breaker. When things go wrong for a long time the circuit breaks and you know in a sensible time that you need to take some action or try again. &lt;a href="https://github.com/Netflix/Hystrix" rel="noopener noreferrer"&gt;Netflix Hystrix&lt;/a&gt; is a useful tool that deals with that. Alternatives to that is &lt;a href="https://www.envoyproxy.io/" rel="noopener noreferrer"&gt;Envoy&lt;/a&gt; (that we use), &lt;a href="https://akka.io/" rel="noopener noreferrer"&gt;Akka&lt;/a&gt; and maybe more that I can’t possibly know.  Note that most of these tools are a lot more powerful that just circuit breaking.&lt;/p&gt;

&lt;p&gt;That should be good for now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Section 3
&lt;/h2&gt;

&lt;p&gt;In an old monolithic system having shared resources was easy. Put them in a folder and share them wherever you want. No problem. Now sharing things is not straightforward. How do you share configuration across services? &lt;/p&gt;

&lt;p&gt;&lt;em&gt;We need a configuration server&lt;/em&gt;. You can think of this as yet another service that just stores configuration we should share between all our other services. There are various tools that do that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/Netflix/archaius" rel="noopener noreferrer"&gt;Netflix archaius&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Spring cloud offers a solution (we use that currently)&lt;/li&gt;
&lt;li&gt;AWS offers its own &lt;a href="https://aws.amazon.com/config/" rel="noopener noreferrer"&gt;config service&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="noopener noreferrer"&gt;Kubernetes&lt;/a&gt; also offers a config service too. (we are heading there at TW)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Yeah cool, but why share configuration?  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“One of the key ways to identify what should be constant from service to service is to define what a well-behaved, good service looks like. What is a “good citizen” service in your system? What capabilities does it need to have to ensure that your system is manageable and that one bad service doesn’t bring down the whole system? “ - Sam Newman, Building Microservices&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Configuration is only one aspect of the answer to the above. It’s just one thing that makes our services consistent and well behaved (hopefully). There is a lot more obviously.&lt;/p&gt;

&lt;h2&gt;
  
  
  Section 4
&lt;/h2&gt;

&lt;p&gt;This to me was the trickiest concept to get in terms with. How do I share functions between micro services? Also, how do micro services talk with each other? How does the Transfer service talk with the User service now?&lt;/p&gt;

&lt;p&gt;OK, regarding sharing functions this is a matter of principle. Here is another quote from Sam Newman and his book Building Microservices:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;My general rule of thumb: don’t violate DRY within a microservice, but be relaxed about violating DRY across all services&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So the answer to my first question is, copy functions across if you need to, but don’t copy them within your micro service. Keep it DRY. Unfortunately school made us feel guilty for copy/pasting things around. It’s not always bad.&lt;/p&gt;

&lt;p&gt;The second part of my questions is more interesting though. How do services talk with each other? To answer that we need to go back to service discovery. When Transfer service wants to talk to User service the following need to happen:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transfer service goes to the discovery service.&lt;/li&gt;
&lt;li&gt;Asks, give me the address of the User service&lt;/li&gt;
&lt;li&gt;Discovery replies with an IP or an address.&lt;/li&gt;
&lt;li&gt;Transfer service does an API call to that address.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is called client-side discovery.&lt;/p&gt;

&lt;p&gt;Client-side discovery is good because there are less moving parts. You are just utilising the existing parts of your system. It’s also bad. The bad thing is that you are tightly coupled with that discovery service. What happens if discovery dies? Also, you need to implement that discovery logic I described above to all of your services. That’s a lot of boilerplate.&lt;/p&gt;

&lt;p&gt;We have an alternative. Server-side discovery. In server-side discovery the client makes a request via a router (a.k.a load balancer) that runs at a well known location. The router then calls the service registry (no you can’t avoid that completely) and you get the address you were looking for. Solution for that method are the following:&lt;br&gt;
    * AWS Elastic Load Balancer (ELB)&lt;br&gt;
    * Kubernetes proxy&lt;br&gt;
    * Marathon proxy &lt;/p&gt;

&lt;p&gt;This is simpler by comparison with the client-side discovery because the service now has to only do a call to the router. No implementation of the discovery logic. Also, if you are on AWS it makes sense to just use ELB. The negative is that you add yet another moving part, yet another network hop in your system. Also whatever you choose to use has to support all the protocols you use (gRPC, Thrift, HTTP etc).&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitoring
&lt;/h2&gt;

&lt;p&gt;If monitoring is important on a monolith it’s twice as important on a distributed system with many micro services lying around. The challenge of finding why things failed can be a nerve breaking problem. To be able to get answers and avoid failure you need to have solid monitoring in place. There are a lot of options here.&lt;/p&gt;

&lt;p&gt;The most important thing is visualisation of those metrics that we collect. On that front &lt;a href="https://graphiteapp.org/" rel="noopener noreferrer"&gt;Graphite&lt;/a&gt; is a monitoring tool a lot of companies (including TW) use.  You can use for example a tool like &lt;a href="https://www.elastic.co/products/logstash" rel="noopener noreferrer"&gt;logstash&lt;/a&gt; to push metrics into Graphite and then get interesting graphs. That  can help teams know when their services perform bad. Collecting metrics like inbound response, error rates and application level metrics are only a start. On top of that you can add alarms that can let your team know when things went bad.&lt;/p&gt;

&lt;p&gt;While this is a great solution it’s not without problems. The biggest problem with Graphite is that services need to push to it, so it can be aware of what’s happening. If there are networking issues or the service is dead then your team won’t even know what’s wrong. Plus it adds another burden to the service. &lt;/p&gt;

&lt;p&gt;Another alternative to that is &lt;a href="https://prometheus.io/" rel="noopener noreferrer"&gt;Prometheus&lt;/a&gt;. With Prometheus instead of services pushing to it, Prometheus pulls the metrics. That immediately alleviates the burden from the services. Also Prometheus offers alarms without the need of extra software. So one less thing to worry about.&lt;/p&gt;

&lt;p&gt;In my eyes there are no clear winners on this. The only clear thing is that if you are not monitoring things you will have a horrible time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic concepts that you need in a micro service architecture
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automate everything, and if the technology you have doesn’t allow this, get some new technology!&lt;/li&gt;
&lt;li&gt;If possible, move to a single-service per host/container.
you need one CI build per microservice&lt;/li&gt;
&lt;li&gt;Focus on maintaining the ability to release one service independently from another, and make sure that whatever technology you select supports this.&lt;/li&gt;
&lt;li&gt;At scale, “partially broken” is the normal state of operation.&lt;/li&gt;
&lt;li&gt;CAP theorem (Consistency, Availability, Partition Tolerance). At its heart it tells us that in a distributed system, we have three things we can trade off against each other: consistency, availability, and partition tolerance. Specifically, the theorem tells us that we get to keep two in a failure mode.

&lt;ul&gt;
&lt;li&gt;Consistency is the system characteristic by which I will get the same answer if I go to multiple nodes &lt;/li&gt;
&lt;li&gt;Availability means that every request receives a response&lt;/li&gt;
&lt;li&gt;Partition tolerance is the system’s ability to handle the fact that communication between its parts is sometimes impossible.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Recaping
&lt;/h2&gt;

&lt;p&gt;So here’s the ingredients you need for a micro service architecture:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Gateway + Discovery service. Software that might be of interest:

&lt;ul&gt;
&lt;li&gt;Zuul&lt;/li&gt;
&lt;li&gt;Eureka &lt;/li&gt;
&lt;li&gt;Zookeper&lt;/li&gt;
&lt;li&gt;Consul&lt;/li&gt;
&lt;li&gt;Etcd&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Some circuit breaker to deal with failures.

&lt;ul&gt;
&lt;li&gt;Hystrix&lt;/li&gt;
&lt;li&gt;Envoy&lt;/li&gt;
&lt;li&gt;Akka&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Some configuration sharing service/server

&lt;ul&gt;
&lt;li&gt;Archaius&lt;/li&gt;
&lt;li&gt;Kubernetes&lt;/li&gt;
&lt;li&gt;AWS config&lt;/li&gt;
&lt;li&gt;Spring cloud&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Monitoring

&lt;ul&gt;
&lt;li&gt;Graphite&lt;/li&gt;
&lt;li&gt;Grafana&lt;/li&gt;
&lt;li&gt;Prometheus&lt;/li&gt;
&lt;li&gt;Zabbix&lt;/li&gt;
&lt;li&gt;Nagios&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There is clearly a lot more to this. This is just one little piece of the puzzle. There are a lot of tools to deal with provisioning of servers, availability based on traffic, orchestration of containers etc. &lt;/p&gt;

</description>
      <category>devops</category>
      <category>developing</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How do you learn from online material? Notes? Live coding? Just listen?</title>
      <dc:creator>George Stefanis</dc:creator>
      <pubDate>Wed, 06 Jun 2018 14:01:38 +0000</pubDate>
      <link>https://dev.to/stefanisg/how-do-you-learn-from-online-material-notes-live-coding-just-listen-3ihb</link>
      <guid>https://dev.to/stefanisg/how-do-you-learn-from-online-material-notes-live-coding-just-listen-3ihb</guid>
      <description>&lt;p&gt;I was wondering what's the prefer method that people follow whilst doing an online course?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Listen and take notes?&lt;/li&gt;
&lt;li&gt;Listen and code as you go?&lt;/li&gt;
&lt;li&gt;Just listen and do something later?&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
    </item>
  </channel>
</rss>
