AWS Morning Brief
aws-section-divider
Audio Icon
Whiteboard Confessional: You Down with UTC? Yeah, You Know Me
About Corey QuinnOver the course of my career, I’ve worn many different hats in the tech world: systems administrator, systems engineer, director of technical operations, and director of DevOps, to name a few. Today, I’m a cloud economist at The Duckbill Group, the author of the weekly Last Week in AWS newsletter, and the host of two podcasts: Screaming in the Cloud and, you guessed it, AWS Morning Brief, which you’re about to listen to.

Links

Transcript

Corey: Welcome to AWS Morning Brief: Whiteboard Confessional. I’m Cloud Economist Corey Quinn. This weekly show exposes the semi-polite lie that is whiteboard architecture diagrams. You see, a child can draw a whiteboard architecture, but the real world is a mess. We discuss the hilariously bad decisions that make it into shipping products, the unfortunate hacks the real-world forces us to build, and that the best to call your staging environment is “theory”. Because invariably whatever you’ve built works in the theory, but not in production. Let’s get to it.

nOps will help you reduce AWS costs 15 to 50% if you do what it tells you. But some people do, for example, watch their webcast, "How Uber reduced AWS costs 15% in 30 days". That is six figures in 30 days. Rather than a thing you might do, this is something that they actually did. Take a look at it. It's designed for dev ops teams nOps helps quickly discover the root causes of costs and correlate that with infrastructure changes. Try it free for 30 days. Go to nops.io/snark. That's nops.io/snark.

Today I want to talk about a funny thing: time. Time has taken on a different meaning for many of us during the current pandemic. Hours seem like days. Days seem like months. But in the context of computers, time is a steady thing. Except when it's not. Things like leap years, leap seconds, Google's famous leap smear and, of course, our ever-changing friends, time zones, combine and collude with one another to make time a very hard problem when it comes to computers. In the general case, computers think of time in terms of seconds since the start of the Unix epoch on January 1, 1970. This is incidentally—and not the point of this episode—going to cause a heck of a lot of excitement when 32-bit counters rollover in 2038. But that's a future problem similar to Y2K, that I'm sure won't bother anyone. 

Time leads to suboptimal architectural choices, which is bad, and then those choices become guidance which is in turn far, far worse. Now, AWS has said a lot of things over the years that I despise and take massive issue with. Some petty and venial, like pronunciation, but none of them were quite so horrifying as a tweet. On May 17, 2018, the official AWS Cloud Twitter account tweeted out an article with the following caption, “Change the timezone of your Amazon RDS instance to local time.” I hit the roof immediately and began ranting about it and railing against that tweet in particular. 

I believe this is the first time that me yelling at AWS in public hit semi-viral status. My comment, to be precise, was absolutely do not do this. UTC is the proper server timezone unless you want an incredibly complex problem after you scale. Fixing this specific problem has bought consultants entire houses in San Francisco. Now, I stand by that criticism and I maintain that your databases should be in UTC at all times, as should the rest of your servers. And I'll explain why, but first:

This episode is sponsored in part by N2WS. You know what you care about? Many things, but never backups. At least, until right after you really, really, really needed to care about backups. That's what N2WS does for your AWS account. It allows you to cycle backups through different storage tiers so you can back things up cost effectively and safely. For a limited time N2WS is offering you a hundred dollars in AWS credits for setting up their free trial. And I encourage you to give it a shot. To learn more, visit snark.cloud/n2ws. That's snark.cloud/n2ws

It's important that all of your systems be in the same timezone UTC, or Universal Time Coordinated doesn't change with the seasons. It doesn't observe daylight saving time. It's the closest thing we've got to a unified central time that everyone can agree on. Now, you're going to take issue with a lot of that, and I'm not suggesting that you should display that time to your users. You have a lot of options around how you can alter the display of time at the presentation level. You can detect the timezone that their browser is set to. You can let them select their time zone in the settings of your application. You can do what ConvertKit—one of my vendors—does, and force everything to display in US East Coast time for some godforsaken reason. But all of those options are far better than setting the server time to local time. 

Years ago, I've been told that this shameful secret exists within companies during job interviews when I asked what kind of problems they're currently wrestling with, and it's a big deal because changing one system requires changing every system that winds up tying back to that. Google apparently had all of their servers originally set to Pacific Coast time or headquarters time, and this caused them problems for over a decade. I can't confirm that because I haven't ever worked there, so I wouldn't know other than stories people tell while sobbing into beers. But it stands to reason because once you've gone down this path, it is incredibly difficult to fix it. 

What's not so obvious is why exactly this is so painful. And the problem comes down to change. Time zones change. Daylight saving time alters when it takes place in the given location from year to year. And time zones themselves don't hold still either, as geopolitical things tend to change. 

Remember that computers don't just use time to tell you what time something is right now. They look at when log entries were made, what happened in a particular time frame? What was the order of those specific events that all came from different systems? When was a change actually implemented? And you really, really don't want to have to apply complex math to logs just to reconstruct historical events in time. “Well, that one was before daylight saving time took effect that year in that particular location where the server was running in, so just carry the two.” That becomes awful stuff, and no one wants to have to go through that. It also leads to scenarios where you can introduce errors with bad timezone math. 

Now, there are a couple of solid objections here, but one of the only ones that I saw advocated on Twitter when I started ranting about it was of the very reasonable form, “Look, most stuff that uses databases in a lot of companies is for a single location at a single company, and it's never going to need to scale beyond that company.” And I don't take issue with that argument. In fact, I would argue that it's correct. I think that one of the problems we have in technology is that we tend to assume everything we build has to be scalable and ready to go across the globe at a moment's notice. And it simply doesn't happen the vast majority of the time, but it's still a terrible direction to go in for something like this because there's going to be an exception that suddenly does require that eventually, and having to unwind all of the time decisions that you've made in an opinionated way in your system is incredibly painful and difficult. Whereas just starting from the beginning, and understanding that all of your systems are going to be operating in UTC makes this a heck of a lot easier. Nobody builds most things expecting to have to scale them massively, but sometimes you get lucky, and surprise. 

Fixing these things after the fact takes tears, and sadness, and fire, and brimstone, and articles on the internet, and people thinking you're dumb when you talk to them about your current architecture in job interviews, and it just doesn't lead anywhere good. So, if you have a choice, and you're debating this in any way, please set your system to Universal Time, my developer instance which is only ever used by me still uses Universal Time. Now, I have something set up in my Unix user profile that will set my timezone of preference to my user. And that's what it displays on the command line and in other things when I tell it to ls or look at a [00:09:15 bunch] of my files, what times are they edited in. But that's all done, again, at the presentation layer. The system time itself is set to UTC. 

Now, to their credit, AWS has since edited the how-to guide that their tweet linked to, and it starts off by saying that changing an RDS system to local time is strongly not recommended. And I do accept and admit that there are times where you're going to need to change RDS to a local timezone just to ensure compatibility with previous poor decisions that you're already suffering from. But it shouldn't be done as a best practice, and it certainly shouldn't be advertised as something that's a good idea. And when you do have to implement something like this, you should feel more than a little dirty about what you're having to do. Because it's not the best practice, it is absolutely something that is going to cause you pain down the road, possibly. And if you can possibly get away from it, you should. 

This has been the AWS Morning Brief: Whiteboard Confessional. I am Cloud Economist Corey Quinn. If you've enjoyed this podcast, please leave a five-star review in Apple Podcasts. Whereas if you've hated it, please leave a five-star review on Apple Podcasts anyway, along with a comment telling me what time it is.

Thank you for joining us on Whiteboard Confessional. If you have terrifying ideas, please reach out to me on twitter at @quinnypig and let me know what I should talk about next time.

Announcer: This has been a HumblePod production. Stay humble.
View Full TranscriptHide Full Transcript