 Good morning, my name is Ricardo Chavarria, if that's a little hard then you can call me Richie, I just turn around when you say that. I work at a company called Neersoft and we do development work for companies in the United States. We're located in Mexico, we have three cities and thanks to them I'm here so I'm very proud to be here today. I'm from the city of Chihuahua, you might know something about us, you might know this dog. We're also a city and we're also a state with big mountains and trains and stuff so if you ever had the chance to go to a conference to Mexico or Chihuahua please come, you're very, you are all welcome. And well so I started doing Raspberry Pi programming around two or three years ago and I remember I bought one and then so I was like you know I can do all this kind of stuff and these projects and it's going to be so fun but I don't know I got bored and I just left it there for a while and you know after a few months I asked some of my friends what are you doing with your Raspberry Pi and most of them were like doing these pirate TV shows and stuff for their TV so I'm like hmm that's interesting so at that time I had a consultancy for local projects in Chihuahua most of them were like webpages and marketing stuff and something like that and so one of these companies was an architect and they were like you know what we need a web page because so we want a project and now we're appearing in all these magazines all over the country and we don't have a website so we're like okay and we also have no money for a server or anything and basically you know this has to be as cheap as possible and I'm like well I had an idea so I set up a Raspberry Pi with Phoenix and we built the website of Phoenix and it was just basically it and so we put it in a it is like a data center in a company there in Chihuahua I have a friend who is that you know the VP of engineering and I was like no one will notice if you put this little box there you know no one will they will know what it is so I just said just put this little box and that was it so and the next month the magazine came up and this this architectural firm got started having visits and stuff and they were like man the the website is so fast and I'm like oh yeah you know these huge servers in the cloud so I was very excited and and it was well before nerves was a thing it was a thing but it was really hard to set up and stuff so I didn't try it at that time and so why didn't I use them by now you know pretty well what nerves is so why didn't I use it well first because it was in an early stage so I couldn't use it yet and then later on when I got the chance to use it I I realized it was not meant for servers so I was like I couldn't use it now that I'm learning a lot of stuff of how you OTP and elixir works but at first I was like I also want to learn how to do this it on my own and so now this is this is what this this being like two years since then the website is still running they just I forgot about it really but they just called me last week and say hey can you renew our domain because we still needed that thing and I'm like oh yeah the domain I need to pay that so yeah so it's still running and I'm very happy with it and so then the next time I got I needed a problem like that I had some problems that I needed to solve and you know what I'm like I have a bunch of raspberry pies there and I don't want to give my money to Amazon yet I give him all the money anyway so these are the other options I had like okay this option is build-on docker and it has an image that you just put it on all of your raspberry pies and you put them up and they start seeing each other and they can balance each other and stuff and so it looked fun this is another option you might know and there's actually a video they have they have even like a list of things you should buy to make a cluster of raspberry pies and stuff and they even have images of SD card you just put in and you know it works this is very funny because when you start doing it they would ask you if you have more than 128 notes so I just look at my raspberry pies and like no no so those projects are great this is our great projects but they don't I could use any language and I wanted to use lexer you know I wanted to learn a lexer so I could use any language with all this project because they do all the balancing for you so this is how it looks you know when I started doing this that's my living room by the way don't tell my clients and so when I start doing this I remember I so I set it up I put up my network my local network and start and started just doing a raspian and set up a lexer and so I started doing some some you know experiments and trying to at least run an app run Phoenix start I start trying to compile on my machine and then try to make deploys and stuff so I let it left the running during my work and it just you know it's just blinking all day and that day I remember Yahoo was hacked and and some of the news said it was you know at this distributed attack with the Internet of Things and stuff and so my brother is the newscaster in my city so we you know when we were to dinner he told my mom before I got there like you know what I think Ricardo is doing this stuff you know so so when I got to my house my mom says me who are you hacking Yahoo and I'm like no mom you know no so so okay so I was like okay I got elixir an OTP in three Raspberry Pi set up so can I how can I make them work for me as the other projects let him so okay this is my new problem that I have in Mexico we are very complicated for everything apparently and our invoicing system has is it's a way way complicated process where it's a neck the the real invoice you make that you need to present taxes and stuff if you want to have a if you want to present expenses all your invoices have to be an XML signed by the person that sold it to you and then side by the government they signed it and then you get it so the funny thing is most people don't care about the XML they just want a PDF you know they don't want they don't want to just they don't want something normal and stuff so right now I'm working on a project that what we want is to download all the XMLs the government once you make all this process the government has all the XMLs so in case someone doesn't send you the XML you don't have to worry it's there it's in the cloud so you download you download all the XMLs and once you have them you have all the information to build a PDF and so make something that humans can read and and that's that's what most people want so the problem is a lot of companies like huge manufacturing companies they receive a lot of XMLs like every day they receive hundreds or even thousands a day because all the time they are buying and selling all their the needs for the factory to work so I'm building a system that will download all your XMLs and generate PDFs and then you'll have it handy and then you just have to log in and you have them there this process will take I mean for it before it to complete it takes like 72 hours so it's not a really critical system and I mean if it goes for an hour no one will notice because it can take up to 72 hours to complete so what I started doing is doing this in an elixir in elixir application and generate them there so I was like all right let's do it in my machine it's really simple you know I just just open another another tab in my terminal and I have two nodes and that's it so to run local I just I just make a loop and start to send it to the other node the work and that's how I know it's you know it's working and and that's it so it looks really simple and this is what you will find on all the books and actually I look at my program in elixir book for this and what you need to do is just send a signal and send which which function you want to execute in the other node and then it'll return you the the result it looks so simple right well as soon as you don't you're not in your local machine it gets a little bit crazy so this is a code to run on nodes so the first thing you'll notice is that when I call notespan I had to call the whole name of the node but turns out elixir doesn't like IP addresses that much so it's better if you if you run it on a or a name you give it a name and then you set it up on your ETC ETC names so so that's the first thing that's different and so what I did is just set up my three Raspberry Pi's in my living room and I started writing and I started writing this this process so I do the same thing it's just a loop but then I start sending it to one of each so if you see that chunk is just to send three of them to each of them and and that's it as you can see as you can see there is the only thing I just I just wanted to show here is that all of my Raspberry Pi's are a hundred percent so that means the work is being distributed along all the Raspberry Pi's and it's not my laptop that's doing the work so I'm was very happy at the point so why did I learn well I need to mess with my ETC host file to give them a name because as soon as you're outside your local laptop everything you do with with OTP nodes starts to you know they want to have a name for that so so I change my ETC host and then that's my command for for starting my nodes all of them have to have an S name in this case you know laptop or Raspberry Pi one two and three and then you have to give it a cookie which is like a passcode so that they recognize each other and then I start so I was running this on a Chromebook and the Chromebook took 20 seconds to finish my 10 loop 10 times loop and when I started using just one node just so just the Raspberry Pi and then one one and the laptop it started to go down to 30 seconds and then when I just to went down to seven seconds when it's three five seconds so I'm like this is working I'm I'm actually you know making distributed work I'm a Rails developer so this is very very interesting this is a whole new world so all right and then I'm like okay but I need to do the same thing with Phoenix and it turns out you can configure Phoenix to do this but you'll need this configuration I mean this is the one I found that work this is actually airline configuration so to find this I had a kind of like a hard time because I I didn't exactly what knew what to ask for like so well what this is saying is that I need these nodes and they are optional so what that basically means is that your application is going to boot and then it will start looking for these nodes and if they are not there well too bad and it will start anyway you can make them to be not optional so that way if they're not there it will turn it will turn off as soon as they don't find it and I give it a 10 second time time out because that's me turn them and turn them on you know I have 10 seconds before I turn on one so it's enough and it's great after after a couple of tries same thing I had to mess up with all the etc host in the Raspberry Pi's now because they have to see each other and and now when I when I get to one of the consoles in one of the Raspberry Pi's I can see the other two nodes and I can send them work now they can see each other so that was very very very happy about it so and as you can see you can also so now that I have it all my three nodes they have a web page I need that because the actual system is built in Rails and it's what the clients will see but all the work is going to be doing in the background with this elixir application and then they are they'll just see their downloaded files so I needed Phoenix because I needed a small web API just to send the server new XML to download once I know they they're there and so I see my Raspberry Pi is working so what do you change well the etc host files has to be changed in all of the hosts we mean all of the machines all of the Raspberry Pi's the command is a little bit different because now that I'm sending a airline application configuration then I need to send that when I start the process and if I need to balance the HTTP load I use HAProxies to to balance the HTTP load any that too I don't think I'm gonna use that in production because it's not gonna be seen directly by any client it's gonna be all in the background downloading XMLs and turning them to PDFs and so it was very fun so in conclusion if you want to do embedded development please use nerves don't get into trouble like me and the other thing is that well everything that I used actually you can use it in Amazon or any kind of server doesn't have to be a Raspberry Pi actually and that was fun to know like because at first I didn't know how powerful elixir was and what parts of the OTP I'm using you you will hear it a lot that that you know they say elixir is built to be distributed all the OTP is awesome and it's way back and you know but this time I was like I want to learn it I would really want to learn it and I really want to know what how it works and it was a very fun experience and just to let you know this system is going live on April so after that I will have more fun of using Raspberry Pi as servers and don't tell my clients I don't think they will able to see this recording so it will be our secret and I think that I will take questions and thank you