<?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: Breno Helfstein Moura</title>
    <description>The latest articles on DEV Community by Breno Helfstein Moura (@brenohelf).</description>
    <link>https://dev.to/brenohelf</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%2F391055%2F32d8720e-bacc-4fed-b7d2-7235674c3d65.jpeg</url>
      <title>DEV Community: Breno Helfstein Moura</title>
      <link>https://dev.to/brenohelf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/brenohelf"/>
    <language>en</language>
    <item>
      <title>You learn the most when you fail - Distributed programming project</title>
      <dc:creator>Breno Helfstein Moura</dc:creator>
      <pubDate>Wed, 20 May 2020 18:00:27 +0000</pubDate>
      <link>https://dev.to/brenohelf/you-learn-the-most-when-you-fail-distributed-programming-project-3aaa</link>
      <guid>https://dev.to/brenohelf/you-learn-the-most-when-you-fail-distributed-programming-project-3aaa</guid>
      <description>&lt;h2&gt;
  
  
  The project
&lt;/h2&gt;

&lt;p&gt;This project was done for network and distributed programming subject of University of São Paulo. The idea of the project was to build a distributed program that would run on different nodes, and it had the goal of sorting an array (using all the nodes in our network). It needed to support the addition of new nodes, death of nodes, and the change of "leader nodes" that would distribute the work load. The array would start in one of the nodes that would act as a "master".&lt;/p&gt;

&lt;h2&gt;
  
  
  Link to Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vWogaON8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-28d89282e0daa1e2496205e2f218a44c755b0dd6536bbadf5ed5a44a7ca54716.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/breno-helf"&gt;
        breno-helf
      &lt;/a&gt; / &lt;a href="https://github.com/breno-helf/Network-Distributed-Prog"&gt;
        Network-Distributed-Prog
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Porgrams done for "Computer Networks and Distributed Systems" subject from University of Sao Paulo
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Redes&lt;/h1&gt;
&lt;p&gt;Porgrams done for "Computer Networks and Distributed Systems" subject from University of Sao Paulo&lt;/p&gt;
&lt;p&gt;Each folder represent a different project. EP means "Exercicio Programa" in portuguese, and it can be translated by "Programming assingment".&lt;/p&gt;
&lt;h1&gt;
EP1&lt;/h1&gt;
&lt;p&gt;We had to code a simple FTP server, with some functionalities. This project had to be done in C.&lt;/p&gt;
&lt;h1&gt;
EP2&lt;/h1&gt;
&lt;p&gt;We had to do a program that would sort an array in a distributed fashion. It had some restrictions, such it had to implement leader election (even though it maybe unnecessary).&lt;/p&gt;
&lt;h1&gt;
EP3&lt;/h1&gt;
&lt;p&gt;We had to follow a tutorial to implement a switch and firewall with OpenFlow.&lt;/p&gt;
&lt;h1&gt;
EP4&lt;/h1&gt;
&lt;p&gt;In this assingment we had to explore a security breach, we choose to explore a CRLF of a specific golang version.&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/breno-helf/Network-Distributed-Prog"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;h2&gt;
  
  
  How I built it
&lt;/h2&gt;

&lt;p&gt;To the project we had freedom of choice. We, (Me and my teammate &lt;a href="https://github.com/matheushw"&gt;Matheus Cunha&lt;/a&gt;) choose Golang for the language and made some "simple" architecture choices. The first one was how to divide the tasks, we choose to divide the array into chunks, that would be sorted in the nodes with the default sort function of golang. The tasks would come from the master node (that has the data), and the receivers of each task would be defined by the leader node.&lt;/p&gt;

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

&lt;p&gt;Then we would send the array back to a "master" node, (The one that started with the array). The master node would then register the array into its filesystem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o5gYdcWj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9fty9ln2n1z2454yno9f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o5gYdcWj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9fty9ln2n1z2454yno9f.png" alt="Simple Architechture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Later, when all chunks are sorted and stored in the master, the master node would perform the last step, that is going though all chunks in order (we would have a pointer for each chunk in memory) and storing them in a heap, doing some sort of "heap merge" that would take O(N * log(chunks)). &lt;/p&gt;

&lt;p&gt;As you may be expecting by the title of this post, the project "failed" in some way. Although it sorted the chunks correctly, it took way more time distributing the tasks than sorting it, so one node used to work better than N nodes (We tested with 1, 2, 3 and 4 nodes, all raspberry pies). The reason it took so long could be many. The extra "leader" -&amp;gt; "master" step (that was required, due to need of implementing leader election, a requirement of the assignment), can be the issue. Maybe its because we used raspberry pies for testing. However, my favorite candidate is the way we decided to transfer the data, through strings that would be parsed by the other side (Serializing and then de-serializing). Just to "compress" the chunk data, would take longer than to sort the entire chunk, which made the whole idea useless.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why failing this project was good
&lt;/h2&gt;

&lt;p&gt;Well, during this project I think I learned a lot of things. More than just exercising distributed and parallel concepts in practice, I learned what is important, how to measure and diagnoses a problem in a distributed environment and how to think solutions for those problems. None of this things would be learned if I didn't fail, and in the end I am glad I failed. The project didn't had any major goal or responsibility and I learned how to not fail in more important projects.&lt;/p&gt;

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