* my name is raffi krikorian
* work on the platform team - responsible for the APIs that developers use to call Twitter
* brady coerced me into giving a talk entitled "energy per tweet"
* for a while i&#x2019;ve been interested in sustainability
* the crux of it is how can we do things better for the planet?
* how can we do things in a way that is not harmful for the planet -- whether this means getting electricity through renewable means, or using things that are recycled
* before we can really talk about energy per tweet, we should talk about some basic physics that i'm sure you've all long forgotten
* there are two basic quantities that i should refresh everybody's knowledge on
* energy and power -- they are intertwined, but their stories are going to flow through the rest of my talk
* energy == work
* there are two ways to think about it
* another way to think about it literally goes back to work. if you were to pick up a kg from the floor and put it on a table, say a meter high, you've done work. you've expended energy. one J of energy to be exact.
* power is the companion to energy in this story
* power is a &#x201C;Rate&#x201D; - its something that you keep on spending
* a watt, for example, is the amount of joules (remember the kilogram weight?) that is spent per second.
* if i were to move that weight from the floor to the table in a second, i would have exerted one watt of power
* but i would have to keep on doing that over and over to maintain one watt
* the lightbulb is probably the most common thing where people interact with power
* a 100W lightbulb is expending as much power as me lifting 100 kilograms (200 ish pounds - more than i weigh) up to a one meter high table every single second and continuing to do that. imagine that. its lifting me, just over a meter, every second to keep that lightbulb running.
* my 13" macbook pro has a 60W power adapter. that's less power than an incandescent bulb. you can see why people switch to CFL light bulbs that only use 23Ws to give the same power as 100W incandescent bulb.
* how does this relate to tweeting?
* there are a few things that i want to pull apart, and they are all core to twitter
* of course, a mobile is in twitter's DNA
* as you know, a huge percentage of our traffic comes from mobile devices from all over the world
* let's look at one of these devices, the iPhone
* when i first ordered my iPhone, i anxiously waited for it to show up
* i remember watching fedex to watch this magical device be shipped from shenzhen china, to alaska via fedex, and then from there to me
* it flew across the world for it to show up at my door.... and then for me to throw away a year later when the 3G came out.
* that&#x2019;s a prime example of globalization
* not only is the device coming from china and being shipped to me, but its components come from all around the world and need to get to china to be put together
* things like the CPU and the video chip need to come in from singapore, and they need to get the silicon from somewhere
* internal circuitry comes from taiwan
* plastics come from oil which probably needs to be shipped in from the middle east
* there is a whole story of the world that is going on in my phone alone
* and just imagine how much energy was spent putting this all together. some estimates put it at 400 megajoules. that&#x2019;s me lifting a kilogram of weight to a table that is as far away as the moon.
* there is something called the basal metabolic rate (BMR)
* that's the amount of energy expended while at rest - mine is 1800 C - basically, that's how many calories i burn by just sleeping all the time
* a small hummingbird, on the other hand, only consumes about 6 C.
* but, look how small it is! i do something like 20 kilocalories per kilogram of "me", where as the humming bird does about 1600 per kilogram of "it"
* small little dynamo
* so - given how much energy is spent at rest, what if you&#x2019;re actually doing something?
* get off your butt, take that iphone i talked about, and sent a tweet?
* for somebody like me, it really comes out to about 1 kilocalorie (big C) to type frantically for about a minute. so, let&#x2019;s say it takes you a minute to compose a tweet. you&#x2019;re burning about 1 calories to pull that off.
* is that a good weight loss plan?
* sarcastically : *maybe*
* we only let you send about 120 tweets every three hours - so you could burn off about 120 calories every three hours (but you would have to type something new every time)
* a mocha from starbucks puts about 300 calories onto my hips, so if i can just cut those off and tweet more, then i would be good. (of course, don&#x2019;t forget you eat other stuff throughout the day)
* so, the biggest question, however, is how much electrical energy does it take for twitter to process a tweet?
* just to get it out in front, i&#x2019;m probably not going to say the actual number, but i&#x2019;ll give some numbers that are in the ballpark
* where do we use energy? we have to power all the machines in our data center. if you&#x2019;ve ever been in our war room at operations in the office, we&#x2019;re power projectors, and screens, computers, VPN links, etc., all to monitor the system. we spend a lot of computing power to smoothly run through our 50 million tweets a day.
* all of this really comes down to our architecture -- which is just a whole bunch of tubes. we have to shuttle tweets around the system in real time.
* its pretty well known that we run ruby and rails (mostly) on our front end servers, and we run mysql as the backend data storage system
* and we have some really great talks tomorrow from people like ryan king, eric jensen, john kalucki, and others talking a lot more about our backend infrastructures. things like how we are changing the servers that are running our systems, how search takes incoming tweets and consumes them, and how we push this data out of our system in real time.
* basically, we have hundreds of computers focused on the problem of ingesting tweets and getting them out again
* thinking about all that gets quickly overwhelming, and if we just want to get a zeroth order estimate -- basically a really rough estimate -- of how much energy, one has to think about the social graph
* fundamentally, twitter has to take an incoming tweet that you send, and put it in the timelines of all the people who are following you.
* the more people who are following you (say, you&#x2019;re barack obama and have 3.6 million followers), twitter has to make sure that tweet gets delivered to 3.6 million people
* if we were to take a postal system analogy, you give a tweet to a mailman who has to then copy that tweet and stick it into the mailboxes of all your followers
* the more followers you have, the more people we have to deliver that tweet to
* followers are like a power law -- a lot of people have a lot of followers, and a lot of people have a small number of followers. let&#x2019;s say, on average, that comes out to about 120 people who follow you.
* the experiment is as follows
* we have a development mode for twitter codebase
* we can run the rals up in dev mode
* but we still start up almost all the relevant portions of the application
* can run the entire thing on our developer laptops to get an almost full twitter experience
* run the development mode version of twitter (memcache, database, etc.) all on laptop
* cleanly restarted laptop
* loaded it up with requests and calling /status/update over and over and over
* basically, trying to max out the system on the laptop to see how much we can push off
* really, we&#x2019;re trying to measure the throughput of the system. we know how much power my laptop is taking, so we just want to pump through the most number of tweets that we can in that time.
* 65W laptop - can push out about a tweet every 1.25 seconds
* multiply those out - its about 90 J / tweet
* google has said that each google search takes about 1 kJ / tweet (10x more expensive)
* good thing - i&#x2019;m running this in development - our numbers in production are more like - 3x less than that
* going with my 90J / tweet number, that&#x2019;s something like 0.02 g of CO2 per tweet
* that&#x2019;s a small number, but small numbers add up - if we put in our 50M per day, then we&#x2019;re talking 1000 kg of CO2 a day
* if we ran all the tweets through my laptop, that&#x2019;s one metric ton of CO2 a day
* again, thankfully, we&#x2019;re better than that