<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Armin's blog</title>
    <description></description>
    <link>http://blog.coralic.nl/</link>
    <atom:link href="http://blog.coralic.nl/feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Sun, 28 May 2017 11:26:33 +0000</pubDate>
    <lastBuildDate>Sun, 28 May 2017 11:26:33 +0000</lastBuildDate>
    <generator>Jekyll v3.4.3</generator>
    
      <item>
        <title>Production ready AWS ECS (EC2 Container Service)</title>
        <description>&lt;p&gt;Original post can be found at &lt;a href=&quot;http://blog.xebia.com/production-ready-aws-ecs-ec2-container-service/&quot;&gt;Xebia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you looking to run Docker containers on AWS? Or are you looking to use AWS ECS (EC2 Container Service)? Does it need to be production ready?&lt;/p&gt;

&lt;p&gt;If so, then speed up your process and be ready today by looking at my &lt;a href=&quot;https://github.com/arminc/terraform-ecs&quot;&gt;GitHub repository on ECS&lt;/a&gt;. It contains infrastructure as code with Terraform for a quick production ready setup. But most importantly it contains information on how the infrastructure is setup. It explains why things are done in a certain way and where to watch for. And finally, shows how to do simple but fully automatic deployments.&lt;/p&gt;

&lt;p&gt;If you live in the Netherlands then join me at the &lt;a href=&quot;https://pages.xebia.com/open-kitchen-simplify-devops-with-aws-ecs&quot;&gt;Open Kitchen: Simplify DevOps with AWS ECS&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 24 May 2017 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2017/05/24/production-ready-aws-ecs-ec2-container-service/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2017/05/24/production-ready-aws-ecs-ec2-container-service/</guid>
        
        <category>docker</category>
        
        <category>cloud</category>
        
      </item>
    
      <item>
        <title>Docker containers vulnerability scan with Clair</title>
        <description>&lt;p&gt;Original post can be found at &lt;a href=&quot;http://blog.xebia.com/docker-containers-vulnerability-scan-clair/&quot;&gt;Xebia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you work with containers (Docker) you are not only packaging your application but also part of the OS. Therefore it is crucial to know what kind of libraries might be vulnerable in you container. One way to find this information is to use and look at the Docker Hub or Quay.io security scan. The problem whit these scans is that they are only showing you the information but are not part of your CI/CD that actually blocks your container when it contains vulnerabilities.&lt;/p&gt;

&lt;p&gt;What you want is:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Build and test your application&lt;/li&gt;
  &lt;li&gt;Build the container&lt;/li&gt;
  &lt;li&gt;Test the container for vulnerabilities&lt;/li&gt;
  &lt;li&gt;Check the vulnerabilities against allowed ones, if everything is allowed pass, otherwise fail&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This straight forward process is not that easy to achieve when using the services like Docker Hub or Quay.io. This is because they work asynchronously which makes it harder to do straight forward CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;##Clair to the rescue&lt;/p&gt;

&lt;p&gt;CoreOS has created an awesome container scan tool called “clair”. Clair is also used by Quay.io. What clair does not have is a simple tool that scans your image and compares the vulnerabilities against a whitelist to see if they are approved or not.&lt;/p&gt;

&lt;p&gt;This is where clair-scanner comes in to place. The clair-scanner does the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Scans an image against Clair server&lt;/li&gt;
  &lt;li&gt;Compares the vulnerabilities against a whitelist&lt;/li&gt;
  &lt;li&gt;Tells you if there are vulnerabilities that are not in the whitelist and fails&lt;/li&gt;
  &lt;li&gt;If everything is fine it completes correctly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;##clair-scanner&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/arminc/clair-scanner&quot;&gt;See here the full documentation about the clair-scanner.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is a simpel example on how to scan a container and verify if it has vulnerabilities:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;docker run -p 5432:5432 -d --name db arminc/clair-db:2017-05-05
docker run -p 6060:6060 --link db:postgres -d --name clair arminc/clair-local-scan:v2.0.0-rc.0&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now scan a container, that has a whitelisted CVE:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;clair-scanner nginx:1.11.6-alpine example-nginx.yaml http://YOUR_LOCAL_IP:6060 YOUR_LOCAL_IP&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</description>
        <pubDate>Fri, 05 May 2017 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2017/05/05/docker-containers-vulnerability-scan-with-clair/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2017/05/05/docker-containers-vulnerability-scan-with-clair/</guid>
        
        <category>docker</category>
        
      </item>
    
      <item>
        <title>Docker container secrets on AWS ECS</title>
        <description>&lt;p&gt;Original post can be found at &lt;a href=&quot;http://blog.xebia.com/docker-container-secrets-aws-ecs/&quot;&gt;Xebia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Almost every application needs some kind of a secret or secrets to do it’s work. There are all kind of ways to provide this to the containers but it all comes down to the following five:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Save the secrets inside the image&lt;/li&gt;
  &lt;li&gt;Provide the secrets trough ENV variables&lt;/li&gt;
  &lt;li&gt;Provide the secrets trough volume mounts&lt;/li&gt;
  &lt;li&gt;Use a secrets encryption file&lt;/li&gt;
  &lt;li&gt;Use a secrets store&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For a complete description and an explanation please see the &lt;a href=&quot;https://elasticcompute.io/2016/01/21/runtime-secrets-with-docker-containers&quot;&gt;following post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Depending on your context all five options might work or are considered good enough. In my opinion to do it right and be safe, flexibel and in control you can only go for option 5 “Secrets store”. Choosing this method it leaves you with different ways to accomplish this. As stated in the &lt;a href=&quot;https://elasticcompute.io/2016/01/21/runtime-secrets-with-docker-containers&quot;&gt;post above&lt;/a&gt; it comes down to this:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Use some form of S3, with or without encryption. For more &lt;a href=&quot;https://aws.amazon.com/blogs/security/how-to-manage-secrets-for-amazon-ec2-container-service-based-applications-by-using-amazon-s3-and-docker&quot;&gt;info see&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.vaultproject.io/&quot;&gt;HashiCorp Vault&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;AWS has released a service called Parameter Store, although it is not as sophisticated as Vault it serves a purpose. If you are starting or want to keep things simpel please try using the &lt;a href=&quot;https://aws.amazon.com/ec2/systems-manager/parameter-store&quot;&gt;Parameter Store&lt;/a&gt;.  But if you need full control and want more flexibility then go ahead and use Vault.&lt;/p&gt;

&lt;p&gt;###Parameter Store&lt;/p&gt;

&lt;p&gt;Parameter Store allows you to store key value data in a key value store with the values encrypted using KMS. Because Parameter Store uses IAM it is a great fit for AWS ECS because you can control the access to the secrets per container.&lt;/p&gt;

&lt;p&gt;I could explain how to do this but luckily AWS has a great post on how this should be done, &lt;a href=&quot;https://aws.amazon.com/blogs/compute/managing-secrets-for-amazon-ecs-applications-using-parameter-store-and-iam-roles-for-tasks&quot;&gt;you can find it here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The blog post is great but I am not really impressed with the run.sh script in which I am replacing the secrets and fetching them with aws cli. There has to be a better and cleaner way….&lt;/p&gt;

&lt;p&gt;I really thought so but we could not find any, so we chose to create one.&lt;/p&gt;

&lt;p&gt;###Dockerfy&lt;/p&gt;

&lt;p&gt;Without trying to invent the wheel again we took the simpel but useful app “dockerfy” and extended it. More information on &lt;a href=&quot;https://github.com/SocialCodeInc/dockerfy&quot;&gt;Dockerfy can be found here&lt;/a&gt;. Dockerfy already handles ENV’s and secret files, and it uses templating for simpel usage of secrets.&lt;/p&gt;

&lt;p&gt;Sadly it did not have a AWS Parameter Store integration but we took care of that, &lt;a href=&quot;https://github.com/SocialCodeInc/dockerfy/pull/4&quot;&gt;as you can see in this PR&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use the Parameter Store and combine it with Dockerfy features to add your secrets using a template but if you need a simpel command-line secret, here is an example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dockerfile:&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;FROM socialcode/nginx-with-dockerfy
ENTRYPOINT &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;dockerfy&quot;&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;&quot;--aws-secret-prefix&quot;&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;&quot;PROD_&quot;&lt;/span&gt; -- &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
CMD &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/bin/echo&quot;&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;To use the above Docker container, store a password in the Parameter Store called “PROD_db_password”. Then provide the AWS keys or run it on an EC2 instance or an ECS service with proper IAM rights and see the secret being echoed.&lt;/p&gt;

</description>
        <pubDate>Wed, 22 Mar 2017 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2017/03/22/docker-container-secrets-on-aws-ecs/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2017/03/22/docker-container-secrets-on-aws-ecs/</guid>
        
        <category>docker</category>
        
      </item>
    
      <item>
        <title>Dockerize your Development Workstation</title>
        <description>&lt;p&gt;This is my Dutch Docker Day talk “Dockerize your Development Workstation”&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/WVGRaApIwkU&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
</description>
        <pubDate>Sun, 14 Feb 2016 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2016/02/14/dockerize-your-development-workstation/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2016/02/14/dockerize-your-development-workstation/</guid>
        
        <category>docker</category>
        
      </item>
    
      <item>
        <title>GTD (Getting Things Done)</title>
        <description>&lt;p&gt;Original post can be found at &lt;a href=&quot;http://blog.xebia.com/2015/09/28/gtd-getting-things-done/&quot;&gt;Xebia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a consultant I am doing a lot of things, so to keep up I have always used some form of a TODO list. The reason why I did this is because it helped me break down my tasks in to smaller ones and keep focusing, but also because I kept remembering the quote I once heard “smart people write things down, dumb people try to remember it”.&lt;/p&gt;

&lt;p&gt;Years ago I read the books “Seven habits of highly effective people” and “Switch”, in my research in to how to become more effective I came in to contact with GTD and decided to try it out. In this post I want to show people who have heard about GTD how I use it and how it helps me.&lt;/p&gt;

&lt;p&gt;For those who don’t know GTD or haven’t heard about the two books I mentioned please follow the links &lt;a href=&quot;http://gettingthingsdone.com&quot;&gt;Getting things done&lt;/a&gt; &lt;a href=&quot;https://www.stephencovey.com/7habits/7habits.php&quot;&gt;Seven habits of highly effective people&lt;/a&gt; &lt;a href=&quot;http://heathbrothers.com/books/switch/&quot;&gt;Switch&lt;/a&gt; and have fun.
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I use GTD?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because of my experience before GTD I knew I needed a digital list that I could access from my phone, laptop or tablet. It was also crucial for me to be able to have multiple lists and reminders. Because of these requirements I settled on using Todoist after having evaluated others as well.&lt;/p&gt;

&lt;p&gt;I have couple of main groups like Personal, Work, Read-me, Someday &amp;amp; Maybe, Home etc.. In those lists I have topics like Xebia, CustomerX, CustomerY etc.. And in those topics I have the actual tasks or lists with tasks that I need to do.&lt;/p&gt;

&lt;p&gt;I write everything in to my Inbox list the moment a task or idea pops up in to my mind. I do this because most of the time I don’t have the time to figure out directly what I want to do with it so I just put it in to my Inbox and deal with it later.&lt;/p&gt;

&lt;p&gt;As a consultant I have to deal with external lists like team scrum boards. I don’t want to depend on them so I write down my own tasks with references to them. In those tasks I write the things that I need to do today, tomorrow or longer if it is relevant in making decisions on the long run.&lt;/p&gt;

&lt;p&gt;Every day I finish my work I quickly look at my task list and decide on priorities for tomorrow, then every morning I evaluate my decisions based on the input of that day.&lt;/p&gt;

&lt;p&gt;As a programmer I like to break down a programming task in to smaller solutions so therefore sometimes I use my list as a reference or micromanagement of tasks that take couple of hours.&lt;/p&gt;

&lt;p&gt;To have a better overview of things in my list I also use tags like tablet, PC, home, tel so it helps me pick up tasks based on context I am in on that moment.&lt;/p&gt;

&lt;p&gt;Besides deciding on priorities every day I also do a week review where I decide on weekly priorities and add or remove tasks. I also specify reminders on tasks, I do this day based but if it is really necessary I use time based.&lt;/p&gt;

&lt;p&gt;Because I want to have one Inbox I am sticking to zero mail in my mail Inboxes. This means every time I check my mail I read it and then either delete it or archive it and if needed make a task to do something.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does GTD do for me?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Pros:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The biggest win for me is that it helps me clear my mind because I put everything in there that I need to do, this way my mind does not have to remember all those things. It is also a relaxing feeling knowing that everything you need to do is registered and you will not forget to do it.&lt;/p&gt;

&lt;p&gt;It gives me structure and it allows me to make better priorities and decisions about saying yes or no to something because everything is in one place.&lt;/p&gt;

&lt;p&gt;Having a task registered so that you can cross it off when it’s done gives a nice fulfilling feeling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Cons:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Having a big list of things that you think you need to do can be quite overwhelming and in some cases it can also feel like a pressure because you haven’t done a list of tasks that is there for a long time. That’s why I keep evaluating tasks and remove things from it after some time.&lt;/p&gt;

&lt;p&gt;Task lists and calendars can sometimes collide so it is importent to keep your agenda as a part of your list although it’s not a list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What am I still missing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Right now from the GTD’s point of view I mis a better time management. Besides that I would like to start a logboek of relevant things that happend or people I spoke to but also incorporate that with my GTD lists (for example combining Evernote/OneNote with my Todoist lists).&lt;/p&gt;

&lt;p&gt;Everything else I mis is technical:&lt;/p&gt;

&lt;p&gt;I mis a proper integration of all my mail where all the calendar invites are working without having to connect all accounts on all different devices. I also mis a proper integration between my mail and Todoist for creating and referencing mail.&lt;/p&gt;

&lt;p&gt;Because I write down every task/idea that pops up in to my mind it would be great if voice recognition would work a little better for ‘me’ when I am in a car.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GTD has helped me structure my tasks and gave me more controle in to making decision around them. By writing this post I am hoping to trigger somebody else to look in to GTD and maybe have an impact on his or hers effectiveness.&lt;/p&gt;

&lt;p&gt;I am also curious in what your opinion is on GTD or if you have any tips for me regarding GTD?&lt;/p&gt;

</description>
        <pubDate>Mon, 28 Sep 2015 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2015/09/28/gtd-getting-things-done/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2015/09/28/gtd-getting-things-done/</guid>
        
        <category>other</category>
        
      </item>
    
      <item>
        <title>Rooting my Galaxy S5</title>
        <description>&lt;p&gt;It’s been a while I have tinkered with my Android phone, I thought it’s time to root and play around. How hard can it be right? I have done this 100 times before. You already know where this is going, 2+ hours of flashing rebooting until it worked…. :)&lt;/p&gt;

&lt;p&gt;There is plenty information about what to do compared to years ago. Mostly if you follow the tutorials it should go right but sometimes it just doesn’t. Let me walk you trough what I did to root my phone and eventually install a custom rom :)&lt;/p&gt;

&lt;p&gt;Download ODIN, there are two version old and new one, the ui is different. Download custom recovery, find the new version on xda forums. Let’s start&lt;/p&gt;

&lt;p&gt;I used the latest odin, connected my phone it starts flashing but nothing else happens it just hangs showing progress bar. Hum lets try and reboot the phone in download mode, pfff it works. Seems odin does not start as system, lets try again, it works and the phone reboots, I reboot in recovery mode but I end up in samsung recovery, wtf. Ooh it seems there is a script that brings back recovery mode, to fix it remove battery when the flashing is done, before the phone boots and then boot in recovery mode to override the script. Watch out not to remove the battery to soon :)&lt;/p&gt;

&lt;p&gt;Custom recovery is there victory :) , make a backup, shit can’t need 8 gig. Lets just root, seems to work, reboot phone, hum stuck on boot screen. Let’s wipe everything, reboot and the phone is still stuck on boot, boot again hum now I see it’s optimising apps… After some time I am in my android but root is broken, damn it. Root again and now the phone is stuck on boot before samsung logo, damn it.&lt;/p&gt;

&lt;p&gt;Now I can’t get the phone to boot in any way, I have two options flashing original with odin, but need to wait 2 hours for a download or install a custom rom. Let’s do custom rom, but how do I install it I can’t copy the zip on to it. Oke no problem let’s sidelode it trough adb. It seem to work, phone is rebooting, damn stuck at boot again. Reboot to recovery again and wipe everything, try again, seems to work phone reboots, stuck on boot again, I wait a minute or 2 and reboot, ooh I see it’s optimising apps. It seems it was working on the first boot as well only it was optimising apps but not showing it. Now I am in a running android with root working whooooo. Finally I can use my phone again.&lt;/p&gt;

&lt;p&gt;Now only thing I need to do is install some of the samsung apps trough recovery to allow exchange support etc.. But also install all my apps and configure them, have no backup of them… Luckily there is lastpass helping with passwords :)&lt;/p&gt;

&lt;p&gt;No mater how many times you have done this it’s alway journey, I really need to fix/root my phone when I buy while I still have my other phone working so I have more time to mess around&lt;/p&gt;
</description>
        <pubDate>Sun, 21 Jun 2015 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2015/06/21/rooting-my-galaxy-s5/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2015/06/21/rooting-my-galaxy-s5/</guid>
        
        <category>android</category>
        
      </item>
    
      <item>
        <title>Continuous Delivery of Docker Images</title>
        <description>&lt;p&gt;This is my Xebicon talk “Continuous Delivery of Docker Images”, here are the &lt;a href=&quot;/assets/files/ArminCDofDockerImages.pdf&quot;&gt;slides&lt;/a&gt;&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/crW9TwuUzc0&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

</description>
        <pubDate>Fri, 12 Jun 2015 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2015/06/12/continuous-delivery-of-docker-images/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2015/06/12/continuous-delivery-of-docker-images/</guid>
        
        <category>docker</category>
        
      </item>
    
      <item>
        <title>Start again with jekkly</title>
        <description>&lt;p&gt;I have not blogged for quite some time now, I just had no fun with it anymore. But as I have done very cool things in the past two years I am actually sad that I haven’t shared my knowledge with the world. I still believe sharing is a way forward for all of us as this is how I learn on the internet as well. I have switched my blog from wordpress to jeklly hosted on github because it is fast and easy compared to the previous blog. I hope this will help me start blogging more even if they are quick posts.&lt;/p&gt;
</description>
        <pubDate>Sun, 07 Jun 2015 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2015/06/07/start-again-with-jeklly/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2015/06/07/start-again-with-jeklly/</guid>
        
        <category>blog</category>
        
      </item>
    
      <item>
        <title>Goodbye Ubuntu, Welcome Arch Linux</title>
        <description>&lt;p&gt;I started using Linux years ago and I tried a lot of distributions but Ubuntu was always my main distribution on my work laptop. The reason why I used Ubuntu was simple, it worked and it did not have a lot of maintenance if you didn’t customize. But after so many years of Ubuntu I needed a change.&lt;/p&gt;

&lt;p&gt;As I said before I tried a lot of other distribution before but always came back to Ubuntu. I think the reason for this is that I never really prepared myself for the switch but I just did it. So this time I wanted to do it differently. First I made a short list of the distribution that I would like to use, this was a quick one.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Arch, because it becomes my system and I decide what happens with it and because it is bleeding edge&lt;/li&gt;
  &lt;li&gt;Debian, rock solid&lt;/li&gt;
  &lt;li&gt;Red Hat Enterprise, I needed a third option&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I didn’t really wanted Red Hat and if I am going to switch from Ubuntu to some other distro I needed a bit more change than there is between Ubuntu and Debian (and no I am not saying they are the same!). I have looked in to Arch before and even installed it on my laptop but didn’t give it a change, my main reason to install Arch is to learn more about what my system is doing and to be on the edge of software. But instead of diving in to it as I normally would I went and prepared myself.&lt;/p&gt;

&lt;p&gt;I read trough the installation, I looked at different options, made my choices regarding boot manager,artitioning, file system etc… Then I installed it in VirtualBox and started configuring and testing the software I thought I wanted to use, this way I tried new software and decided on my defaults. After that I went and installed Arch on my laptop and since 4 weeks Arch is my main distribution that I love!&lt;/p&gt;
</description>
        <pubDate>Sun, 17 Nov 2013 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2013/11/17/goodbye-ubuntu-welcome-arch-linux/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2013/11/17/goodbye-ubuntu-welcome-arch-linux/</guid>
        
        <category>linux</category>
        
      </item>
    
      <item>
        <title>Parallelism simplified by Akka in Java</title>
        <description>&lt;p&gt;I have bean writing applications in Java EE environment for some time now and I didn’t need to worry about creating own threads. When I needed to create and manage my own threads it always felt wrong because of to much low level programming. Then I came across akka and wanted to try it out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Akka?&lt;/strong&gt;&lt;br /&gt;
Quote from &lt;a href=&quot;http://akka.io/docs/&quot;&gt;akka.io&lt;/a&gt; “We believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it’s because we are using the wrong tools and the wrong level of abstraction. Akka is here to change that. Using the Actor Model we raise the abstraction level and provide a better platform to build correct, concurrent, and scalable applications. For fault-tolerance we adopt the “Let it crash”; model which the telecom industry has used with great success to build applications that self-heal and systems that never stop. Actors also provide the abstraction for transparent distribution and the basis for truly scalable and fault-tolerant applications.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt;&lt;br /&gt;
For the purpose of the sample we have a trivial working unit that simulates CPU intensive task that can find a factorial for a large number. We assume that we need to find factorials for many different numbers, for the purpose of consistency the number is now fixed.&lt;br /&gt;
Factorial calculator&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CalculateFactorial&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BigInteger&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;calculate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;BigInteger&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fact&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BigInteger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;valueOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;739&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;fact&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fact&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;multiply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BigInteger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;valueOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fact&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;Java way&lt;/strong&gt;&lt;br /&gt;
The most simple way of implementing this is to loop through the numbers and calculate the factorial for them, like this.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;JavaWay&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;JavaWay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;calculateFactorial&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;printElapsedTime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;calculateFactorial&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CalculateFactorial&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;calculate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());}}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;printElapsedTime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Time&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Done: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;elapsedTimeMilliseconds&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This is a simple solution that works well, but the problem with it is that the processing speed entirely depends on one thread on the local machine even though the messages could be processed simultaneously. It is possible to solve this problem in many different ways, for example by using a container managed environment. Although it can solve the problem it brings complexity and overhead to the project. Another way is to use threading, but that means working on a low level coding and it does not allow distributed scaling. But there is also Akka way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Akka way&lt;/strong&gt;&lt;br /&gt;
Akka can be used as a library like in this sample, as a microkernel or part of the Typesafe Platform. This sample consists of four parts: bootstrapping Akka (starting ActorSystem), master actor that handles the messages, worker actor that handles the calculating process and at last there are triggers (messages).&lt;/p&gt;

&lt;p&gt;Bootstrapping Akka consists of starting the ActorSystem, creating the master actor and telling it to start processing.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AkkaWay&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;AkkaWay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ActorSystem&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ActorSystem&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;CalcSystem&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ActorRef&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;master&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Master&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;createMaster&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;master&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;master&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;tell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Calculate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ActorRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;noSender&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Master actor is responsible for processing the messages, meaning telling the Worker actor to calculate the factorial. Akka has different ways to scale, in this sample RoundRobinRouter is being used so that multiple Worker actors can do their work at once. Master worker is also responsible for receiving the results from the Worker actors and knowing when all messages are processed.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Master&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;UntypedActor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;processed&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ActorRef&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;workerRouter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Time&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ArrayList&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ArrayList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Master&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;workerRouter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;createWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;withRouter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RoundRobinRouter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;workerRouter&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onReceive&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;instanceof&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Calculate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;processMessages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;instanceof&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getFactorial&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;unhandled&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;processMessages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;workerRouter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;tell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Work&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getSelf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());}}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Done: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;elapsedTimeMilliseconds&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;getContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;shutdown&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Props&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createMaster&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Master&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ArraySeq&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Worker actor is responsible for the actual factorial calculation and returning a response to the parent (master actor) when done.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;UntypedActor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onReceive&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;instanceof&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Work&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;BigInteger&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bigInt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CalculateFactorial&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;calculate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;getSender&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;tell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bigInt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getSelf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;unhandled&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Props&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ArraySeq&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;For communication between actors Akka uses triggers (messages) that are immutable objects.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Calculate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BigInteger&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bigInt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BigInteger&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bigInt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;bigInt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bigInt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BigInteger&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getFactorial&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;bigInt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This is all the code that is needed to take advantage of parallelism. If local scaling is not enough Akka also has a simple distributed solution build in that allows the Worker actor to be run remotely without changing the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Speed: Java way vs Akka way&lt;/strong&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Messages&lt;/th&gt;
      &lt;th&gt;Java (milliseconds)&lt;/th&gt;
      &lt;th&gt;Akka quad (milliseconds)&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;100&lt;/td&gt;
      &lt;td&gt;53&lt;/td&gt;
      &lt;td&gt;38&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1.000&lt;/td&gt;
      &lt;td&gt;302&lt;/td&gt;
      &lt;td&gt;139&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;10.000&lt;/td&gt;
      &lt;td&gt;2661&lt;/td&gt;
      &lt;td&gt;1072&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1.000.000&lt;/td&gt;
      &lt;td&gt;247579&lt;/td&gt;
      &lt;td&gt;102315&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br /&gt;
This sample shows that it is quite easy to take advantage of parallelism by using Akka to speed up the application. Because Akka is on a higher abstraction level than threads themselves it is possible to speed up the application even further by changing the actors number or by running it distributed.&lt;/p&gt;

&lt;p&gt;Sources&lt;br /&gt;
The working project and the complete code can be found on &lt;a href=&quot;https://github.com/arminc/AkkaTestJava&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For more information there are books like &lt;a href=&quot;http://www.artima.com/shop/akka_concurrency&quot;&gt;Akka concurrency&lt;/a&gt; and &lt;a href=&quot;http://www.manning.com/roestenburg&quot;&gt;Akka in action&lt;/a&gt; or watch a talk from &lt;a href=&quot;https://www.youtube.com/watch?v=t4KxWDqGfcs&quot;&gt;Jonas Bonér&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Fri, 30 Aug 2013 00:00:00 +0000</pubDate>
        <link>http://blog.coralic.nl/2013/08/30/parallelism-simplified-by-akka-in-java/</link>
        <guid isPermaLink="true">http://blog.coralic.nl/2013/08/30/parallelism-simplified-by-akka-in-java/</guid>
        
        <category>java</category>
        
      </item>
    
  </channel>
</rss>
