thank you my name is Henrik I'm from University of all who so I'm a researcher but I would say that primarily I'm a teacher an educator so I'm going to talk about my research field and what I teach most of the time soft architecture and of course it's about in Energy Efficiency something about sustainability and saving the world and all that stuff and then there's this subtitle for developers because I focus my teaching very much on part-time education which is people from industry coming in to to listen to me and do some exercises and what I like to to teach is techniques that actually do things in practice you know so less mathematical rigor but you know things you can pull down and shelf and then actually make things happen Okay so uh so I'll I'll start with a small example uh I'm going to talk a lot today about tactics or the science decisions in order to make your software more energy efficient and one of these is except lower fidelity or don't develop or use features that waste a lot of energy so I'm going to to take a concrete case of something we could imagine a system you know you have a conference session and then there's some speakers up here and then you want to ask a question so how do we solve a problem of asking a question to the lecturer we could develop an app we could develop an app so I can take my mobile phone and spend some energy downloading this app and then I could spend some energy running this app and then I could spend some energy typing in my question on this app and then I said send and then we spend some energy on the wireless to send it to some access point which spends some energy to make it to a service system and then there's a service system energy to receive that request so store in the database and then later this good guy would spend some energy on his mobile phone to fetch all the data from the server and then he would use his voice dear Henrik there's a question here so this is one solution I would call it solution a okay there's a solution B it has works in the Stone Age the only energy it uses is right red energy you just wave your hand and say Henrik could you please okay so I think this is what Energy Efficiency about and this is one of the tactics avoid feature creep okay or avoid Bulls sorry except the law Fidelity and then take the Lesser Road the most energy efficient Road I've sold in this problem okay so now the stage is sort of set you know so actually I discussed with the Tina that I I've been working in this half a year and then she correct me about a year so so I started out as a novice in Energy Efficiency a year ago and now I'm not quite a novice anymore but we actually started out with some companies coming to us and say we need to talk about sustainability and equal footprint and stuff like that and then I looked into it and I thought oh whoa this is a big topic and I'm just a software architecture I'm very much into coding so how do I attack this but there's a big topic and if you didn't see the the presentation last Monday go see it and on the YouTube channels or whatever it's it's it's very nice I'll limit it very much to what I call in Energy Efficiency so basically the idea is that we need to supply some service to a user and we can do that in architecture a and when we use architecture a spend some energy in architecture B Rewritten as a code in another way then it spends another amount of energy and Energy Efficiency is basically choose the one that gets a job done with the least energy I just made an example of asking questions but again you it's basically that's what's down how do I get my computer to do as much as possible for every watt of power that we consume okay I'm originally a physicist so I've been doing computers a long time and that's bits and flipping and then and finally I found myself in my old Turf you know we're doing measurements I'm measuring real stuff that happens in the physical world and I think that really great and one thing that really makes me happy is that in order for you guys to become better programmers at doing energy efficient architecture and design you have to understand the physics so that's nice but but physics you know and it is basically a amount of work measured in joules and Jewel is a rather small scale so if I eat 100 grams of my favorite mayonnaise is about three million jewels okay and I know that because it takes me about 35 minutes of sweaty bicycling to burn the same amount of of jewels we talk a lot about electricity and there we often see how many Jews do we use per second that's a what so basically uh it's it's the flow of energy we measure when we measure Watts and of course you can then say if I use 1000 joules in one hour then I got a kilowatt hour and you can just do the calculations but basically that's the same same thing motivating example how many of you have seen Gangnam Style okay you're bad guys no but I found this wonderful paper who who found the data and it was shown 1. 7 billion times the first year and then they dug into the YouTube and how much energy is spent on on streaming one YouTube video and then you type multiply that too and then I found it the average yearly energy electricity energy consumption by a Danish household a puzzle whose and then I found that the the energy is spent streaming Gangnam Style is about 70 000 Danish houses yearly electricity consumption and then I was thinking is there a morale here I hinted perhaps I said you are bite guys but you know I don't think there's a morale here but but it's at least thought provoking right well what are we spending our energy on and and I don't think we shouldn't look Gangnam Style or YouTube videos and stuff like that that's on the wonderful stuff out there but perhaps we should try to lower energy uh consumption so if it's only 30 000 houses I don't know okay but interesting I think so energy is work done uh Hardware spends energy why does it spend energy is because our software wants of software is running on it and why do we write software that's because the boss told us to oh you know there's some users who are happy about the software we we write hopefully it is like that so we we have to make this relation between the hardware and the software and it's very manifest when we're talking about writing code that's energy efficient and now let's start by the hardware and I must say the hardware guys and then your Hardware guys here sort of you know you're the good guys Applause you're doing a marvelous job okay so this is basically a line that shows how much computation can you do for one kilowatt hour uh kilowatt hour over time you know starting in the 50s and it's amazing curve so every two and a half years you know you can do twice as much computation for the same amount of energy so that's really really nice it's slowing a bit now but still you know good guys you're doing a wonderful job and then there are the guys who write the software any anyone in here writing software you are the bad guys you're the bad guys because as with said already in the 1990s he said that software is getting slower more rapidly than the hardware has become faster I just got this laptop last year and then I'm University guy so the I. T Department did wonderful security stuff on it which means that when I boot it it takes one minute to boot right I have an Amiga 2000 it's from 1991 and in the boots you know I turn on the boo it's there okay so so much for progress just a simple thing I use Virtual machines for my courses I I found this it should be the most raw buncher you can find so I found Loop onto any one knows what the L is for lightweight Ubuntu so I choose the light way Ubuntu in in 16 it was about one gigabyte and it ran nicely now six years later it's two and a half times yeah and it can hardly run in four gigabytes frame lightweight Ubuntu right and the the fun thing is it does absolutely nothing more than the old one did so what the hell I've put in there I don't know and then there's Windows 98 yeah okay so we have to look at what computers spent the energy on I I looked for data and I found this pretty old data for a gaming computer but the basic idea is it's more or less the same the numbers are changed a bit but there's some consistency in this so in the blue I've saved the hard disks and the ram modules and they amount to about 18 Watts so what's that's what they take from a computer and then I with the red boxes I took whatever happens which is rated to the CPU and first of all the CPU spends an awful lot of energy and what happens when an off in CPU is doing a lot of work it gets hot so what do we do we have to cool it down okay and what how do you cool it down you spend energy cooling it right anyone been to a server room you know in the inside of the two racks you know it's really hot in there so the the point here is that they're not the bad guys it's a CPU we should look at so basically everything that is ready to the CPU you know also hence the cooling so so all the energies by basically going there then there's only a known that works and if you have a device a screen is the culprit and stuff like that but I'm mostly in the developing server software so so these are the numbers I'm mostly interested in but the the memory is cheap basically okay so I've made a lab you know I'm a physicist I want to measure stuff so I found this on the Shelf it's fun 2012 and it's basically what I would call a secretary doing email kind of machine and I made that the core of my lab so I'm going to show a lot of numbers measuring from this one I call it The Lunchbox you know it's a very nice little computer and then I actually also found another it was a high-end gaming computer and I really felt good about installing Hitler's Ubuntu on a high-end gaming computer you know this poor graphics card is sitting there no one wants to talk with me anyway but but that actually made the load so I'll miss a lot of automatic load scripts that just hammered away on this small small box that box has over the last half year done more work than it has ever before in its full lifetime it has been happy if I measure the power consumption when it's doing nothing it spins about 11 watts and if it's doing Full Throttle it's about 43 43 Watts so this is sort of my my very humble lamp is that I've done a lot of measurements on and now you think come on Henrik I'm deploying 100 000 services in the cloud and you want me to listen to anything about a computer that size you must be stupid but but the point is a computer is a computer it's a physical device it's electrical device and CPUs or CPUs and Rams or Rams so of course you can't use my numbers I've measured them in but the basic thing this is not about the exact numbers about the trends so if the architecture a is 10 percent more efficient architecture B it might not be ten percent more efficient in the cloud but it's probably 8 or 15 or something so the trend is what we are we are aiming at here what I measure on this one will scale to uh the big systems and if you found I'm wrong please send me an email okay I'm okay so how do we do it yeah and again one year uh ago I I knew nothing so I started looking and this is my man mind after half the year of you know what I've come across uh it's a big topic there's a lot of stuff out there there's a lot of papers there's a lot of blog posts and there's a lot of things but I try to distill it down so this has led to yeah some of the main contributions especially that one is very nice and it's all related to the paper work in progress you can find on this link where try to sum up everything I know or the tactics all the design princes I've found in some some categories and some some concrete advice that you can apply in your programming in your architecting in order to reduce energy consumption so please visit it and be and come some comments I I would love that but let's let's talk about something it's divided into processes and more concrete what do I do at the keyboard so let's let's start with the processes how do we handle the process of developing architecture efficient software and the first thing is you need to need to measure you need to do experiments okay and first of all you need to experiments in order to find that architecture that saves energy to compared to the other architectures that you have of course that and as I said you just steal your computer from your mom and and start doing it there okay so it's important to do measurements but it's also extremely important to get an understanding of what works and what not I've had a lot of shurika aha moments for the last half year doing measurements on that I started out saying well I can probably save five point five percent energy or one percent energy now it's 30 percent energy okay and that was whoa how did that happen Okay but uh so so it's a norm enormously important to do the experiments in order to get a feeling of what what works I think that's that's important just as important as the actual measurements how do you measure then I bought this one it cost 150 krona and it's a power plug you just plug it in and then your computer in the other end and then you have a nice app where you can read okay it spends five Watts at the moment okay it was great I began to feel a bit bored because I had to look at my phone all the time which is which is not not a scientific and accurate but actually in all modern CPUs since 2010 or something it's built into the chip so you just install power stat and Linux and then say measure all the energy consumptions on the CPU for the next 24 minutes and you get long tables of all the power consumption and it's it's only the CPU so you don't get the fans and stuff like that but they correlate so it's much better to to measure it directly on on this CPU and if past that on Linux and then you can use a power catcher I think on Windows but you need the raw machine again find your mom's PC or something you know still PC virtual machines look at the cost but this that probably correlates okay measurements it's physics so uh you need to control error sources you need to do statistical measurements and stuff like that as I I could talk about that for an hour about the read the paper that's a really good paper about how to control that so measuring experiments most vital the other thing is of course prioritize where you're looking you know it costs a mental resources and programming time to refactor your design to become more efficient so of course you should spend that on the the part of the code that's handling 1000 transactions per second right not the one that runs every Tuesday night quite obvious and the other thing is talk to your colleagues talk to The Architects talk to the testers talk to to everybody and increase the awareness of this very simple example this is my kitchen there's one bulb turned on and then there's another bulb turn on and this one spends 40 watts in that two Watts so tell the kids which one to use right it's the same with coding you know tell your colleagues what what works and what not in order to increase that awareness of often it's small small Investments and then you get a lot of return okay so we uh we're coming to the tactic session what do we do when we sit at the keyboard what do we do when we draw nice diagrams at the Blackboard and discuss so I'm trying to unfold all these so there's a lot of a lot of different things you can do I'm going through some of them um but they are under seven main categories which will uh walk about but again find all the all the details in the paper and please give me feedback on all of them so I go through some of them and the fun thing is these each of these categories actually relate to something we couldn't do at home and do at home you know so the first thing is shut down when idle and it's the same thing as god dammit turn off the lights on the bathroom when you leave it right okay yell at that the girlfriend or boyfriend and and the kids you know so if an equipment is not used turn it off right anyone doing microservices yeah anyone embarrassed that they're still on the monolith yeah you know microservices whoa the great thing five years ago ten years ago everybody should move there and and of course it has a lot of Promise because of that independent scaling right you have this web shop you have all these browsing components and when there's a lot of browsing you have services that but you only run three for sales because it's there's no sales and then Christmas comes and then you oh you scale up on the sales component and the good thing about is that when there's no sales again you can scale it down and then save a lot of energy so it has a lot of promise you can do uh kubernetes and uh uh platform as a service and they can do all marvelous things but at this this talk a week ago in Copenhagen and and everybody got that I asked how many do microservice and no one raised their hands and they had this pained pain in the eyes because I'm one of this developer I need to get grips with what's coming on and the young guys will take over my job and stuff like that so a lot of fear but then I showed them this slide if you're not using that scaling microservices spend a lot more energy okay so I did this simple thing it's called Pizza Land it's a pizza ordering system there are two boundary context one is the inventory system the other one is the ordering system and then I ran it both as a monolith 20.
3 millijoules per request microservice 36. 6 millijoules so the microservice architecture will not utilizing the scaling is spending one time 1. 8 times as much energy and all these monoliths developers that said yes now I have an argument for my boss so keep keep your monolith as long and when the independent scaling is a necessary necessity then you should move on there okay anyone going to a vacation putting a lot of stuff in a suitcase and when you come back you find that all your socks are still there the same way that you placed it right yeah okay so the same software don't pack a lot of stuff you're not using and it goes for the the docker images deployment things you know there's been some very good talks about greatly am here lately at the go to conference and one of the promises is you only pack whatever software you actually need so you you don't transfer a lot of software you're not going to use you don't spend a lot of energy unpacking it Etc so try to try to minimize the payload of your executable dog images find the good base images in order to to get the minimal footprint of course it same goes with network payloads you know don't send a lot of stuff you're not going to not going to use buy a lot of stuff at the grocery at supermarket in one go you know going to the Sewer magazine driving back and then found ah we forgot milk and then go to supermarket and buy milk and then you go back and oh we forgot to buy bananas you know it's not efficient same thing about Network traffic and there's a well a lot of different names for it but it's called batch method uh basically that transfer a lot of the information you need now and in the immediate future in one big bulk instead of doing a lot of talking I actually have an example from my um Bachelor course they're developing a card game anyone playing Hearthstone oh you should it's a nice game but basically a card game you know okay and I'm teaching object-oriented programming a nice Paradigm but but one of the thing is that objects have a very fine-grained API so here's a card interface get name get Mana cost get attack get health get out blah blah blah blah blah blah get get get get and in order to draw this one what do I need to call all of them yeah and if this is a remote call get get get get get get get get get get get get that was one card okay get get get get get you get it right that wasn't even intended Okay so so if we write that and uses J uh Java Mi or dot net remote you you get all these chatting things so actually I teach my students using my own broker pattern so I could rewrite handwrite the code to do box fetching so I bulk transfer all the attributes of the card and install it for five seconds until doing another ball transfer very simple 27 energy is saved that's quite a lot and that's only on the server side I only measure the server side the client side I haven't measured I must admit but it's probably among the same amount of savings and the network traffic much less Network traffic so huge savings up with doing a shopping list and then get a lot of data transferred in one go foreign we do a lot of cooking and one thing I really hate is this fantastic Thai Dish and then we have run out of soy sauce or ginger root or something so we have another store besides the kitchen where there's a lot of things pile up so we can just pull it from there we are never out of elements mayonnaise we buy a lot of stuff and put them okay so basically in Computing is called caching okay get the data closer to me so I don't have to go a long way in order to to fetch the data the example I just had before is an example of catchy catching okay get the card data here and then I just use that from local memory for a long time content delivery networks is basically the same thing which says a lot of a lot of energy okay we should use efficient technology in 2012 we were all ordered by the EU to throw out the old bulbs and and use LED bulbs and that that's fine so of course we can save a lot of energy in 2017 there was a fantastic study by some Portuguese guys and it was also referred to in on the Monday slides which tried to run Benchmark in a lot of different languages and then compared the Energy Efficiency C being the Baseline okay how many of you see programmers awesome how many are python programmers some okay you know python didn't score well but I was a bit concerned because you know what were the benchmarks it was Computing the mantle broad sets anyone knows what the mantle bar set is okay how many of your companies make a living by Computing mandrel off sets it's basically a fractal graph you know we don't sell that stuff you know we don't sell any body simulations or DNA sequencing or something or future but anyway so I think I'm trying to do a more realistic one so again I took my three input rest service and develop it at the Java implementation I'm a Java programming and then that's why I learned go in order to do this but go well three and a half percent saved on the same service then my kid is learning Scarlet okay so I thought I better also learn Scarlet plus 27 percent okay and then I did python and the first thing I noticed what python couldn't cope with the load that these handle easily so I had to recompute the amount of energy to per transaction in order to get this number because they did seven 700 transactions per second and this could barely a hand with 1400 Cent selection but still you know 162 percent more energy on doing exactly the same so next year we meet I see no hands on python programmers right one thing I'm also very happy about is I was really fearful that I had to learn C again or go but you know it's okay you know and I think because the virtual machine developers has tuning this machine for ages and the python guys interpreter developers you're going to do the same thing right to save this environment stuff like that okay use efficient databases anyone doing single databases and the rest are lying okay nosql databases anyone ah yeah yeah okay but again I mean you know single database are awesome creatures they can do queries and stuff like that but if you'd only just store things in them and then retrieve the same thing you're basically just a key value store you're using the single database for and they're much more efficient implementations of that so I again I did my rest endpoint three endpoint thing and it was a baseline with the mongodb no SQL database but with a pretty good query language and then I change to radius and saves 31 energy on that one inside one any percent that's good it's good and I was thinking you know two is it no 31 so again consider what your database should do and then pick the one who Spencer least energy okay one thing that's extremely important to know about is the non-proportionality of energy consumption and that basically means a computer that's doing absolutely nothing may spend 100 watts and when it's doing full power as much as is possible can CPU at 100 we're running 200.
Watts and what does that mean that means that we should it spends an awful lot of energy doing nothing so it should do something right here the same grass from this one is for this little guy the red line is the wall outlet power and the blue line is when I measure on the chip and the first thing which is nice they correlate so the trend is the same that's nice this is for a more common server machine it's an Xian processor and then you see that actually the it's 60 doing nothing and about 90 doing a lot of stuff you know so there's less uh the central difference when it comes to server machines I think it's because they're built to be doing a lot but what does that mean that means that I've have a single server let's say at 100 CPU it can hand in 2 000 transactions per second right that's the maximum it can can handle and we can go in here see it's running 100 CPU that's 90 Watts okay get me 90 watts to handle 2 000 transactions per second now we do horizontal scaling load balancing stuff so what do we do now we handle the 2000 transactions by giving 1000 transactions to one machine and one thousand to the other machine and then we go in and say what does it spend here 75 Watts so exactly the sound same amount of work is now spending 150 watts instead of 90 watts of course you also have to run a load balancer so we can put that on top of the energy budget here okay the morale the same thing as my wife does when she bakes buns bake a lot of buns in one big chunk so we use our CPU slash oven as efficiently as possible how many of you have on premise data centers View what are the do you know the average CPU load on your service no idea and and what's the point on premise actually count providers are much better they're running in the region of 60 70 percent load on their computer so it's it's okay on-premise typically runs 15 to 20 load and why is that because you know that if your server crashes then the boss will be yelling at you the next two months so you say I better make sure I double the energy and then I'll double the amount of service and I put a bit on top so I'm completely sure that the boss won't yell at me but it's a bad strategy energy wise you should run your CPUs at hundred percent oh okay have some time bad okay bad bad you can run your CPU 100 load if you do batch processing how many of you do batch processing ah actually go back and make a hundred percent okay if you do server systems which are interactive which are responding to things coming from The Outsider you know social media net banking banking and all these you know transactional web shops and stuff like that and you don't know what the load on your machines are it's governed by Q Theory and the basic idea you should not run your Q system so on 100 you should try to find that knee if you don't know what Q theory is has anyone been stuck in a Queue at the highway in the rush hours yeah have you tried to run the same distance to an eye two o'clock in the night you know what Q3 theory is random events make sure that the waiting time response time is extremely long when the there's crowded you know so you have to run down at 70 on your server systems but no lower please all physical machines use cloud computing in order to group a lot of virtual machines on the same thing so we can drive CPU load up pool things use thread poles connection poles I try to rewrite the same simple system that had a Maria device storage using a naive thing you know I have a request I'll make a connector to the single database I'll do the single query and then I'll turn off the connection and then I tried using a a thread pool or sorry a connection pool again almost 30 percent energy saved by not having to make a connection and then tear it down again and now let memory stuff going on lower fidelity means make our users used to that it's not quite as polished you know one thing you know your images and videos downscale them it's much easier to transfer if if an image if it's at a lower quality you know so of course I know we get a less fantastic experience but we save a lot of energy and we have to train our users and ourselves to make that trade-off in our in our our systems service systems anyone doing locking yeah anyone who have a fear that we perhaps lock a bit too much yeah you know you're young guys you know you come in well happy we don't do any locks and then it crashes and this boss yells at you for two months and then you say I'm going to do logging because I have to find out what's happening and you do a lot of vlogs [Music] those locking is expensive I just turned vlogging off from again three end points and what was the locking it was only one lock message for each get and post request let's say I've been hit three locks in this and then I turned it off and saved 11 of energy and this was not humio an elk stack or something it was simply Docker writing stuff to the file system 11 11.