Podcast Search

Developing Perspective

#143: Bare Metal.

Select a time to play from there. The line being spoken is highlighted as the audio plays.

0:00:00Hello and welcome to Developing Perspective.

0:00:03Developing Perspective is a podcast discussing news of note in iOS development, Apple and

0:00:06the like.

0:00:07I'm your host, David Smith.

0:00:08I'm an independent iOS and Mac developer based in Herna, Virginia.

0:00:11This is show number 143.

0:00:13Today is Tuesday, September 17th.

0:00:15Developing Perspective is never longer than 15 minutes, so let's get started.

0:00:19All right, so today I'm going to be unpacking, taking a break from, I guess, the iOS 7 stuff,

0:00:25new iPhone stuff, all the things I've been talking about recently, and go back a little

0:00:29bit to something that I talked about for a while before, which is Feed Wrangler and talking

0:00:34about some of the more web service side of things there. And specifically I'm going to

0:00:39be unpacking my experience of the last few days and some of the lessons I've learned.

0:00:44So just a quick bit of background, Feed Wrangler, soon to be pod Wrangler, is a system that

0:00:50I built that is a RSS aggregating syncing service. So it's a replacement for Google

0:00:55in a lot of ways that hopefully adds a bit more value

0:00:58and does things in another way beyond that.

0:01:01And this is a service that I launched,

0:01:02I think it was back in May-ish,

0:01:04it was about something like that.

0:01:06And it's been doing pretty well.

0:01:08It's definitely been meeting my expectations

0:01:09and doing well, sort of doing well

0:01:12and being a significant interesting part of my business.

0:01:16And as a result of, sort of,

0:01:19feeder-angler at its core is a sync service.

0:01:23It's something whose purpose is to take

0:01:26rather remarkably large amounts of data,

0:01:29essentially from RSS feeds all over the internet,

0:01:32aggregate them together, and then let people browse them

0:01:34in an easy interface, providing a good API for third party

0:01:38clients, and so on.

0:01:39And so it's something that I built initially

0:01:43on using virtual private servers,

0:01:45specifically at Linode.

0:01:47And it's something whose performance characteristics

0:01:51have always been complicated.

0:01:53I think by the nature of what it's doing,

0:01:58there are certain problems that are just part of it

0:02:01that are inescapable, that no matter what you do,

0:02:03it's just a hard problem to solve.

0:02:06There's a lot of data.

0:02:07There's a lot of, just the sheer bandwidth of items

0:02:08that I'm trying to manage and sort and deal with

0:02:12is pretty remarkable.

0:02:15I think that the simplest version is that right now,

0:02:17I think the database that sort of stores all the articles

0:02:21manages them I think is up to about 200 gigabytes or so.

0:02:25So about 200 gigabytes of data in just about six months or something of work.

0:02:29And so it's quite a lot to keep track of and to manage.

0:02:33And I built it using virtual private servers at Linode, which was something that I

0:02:37was very familiar with and it worked well for me in the past.

0:02:41And it had, however, what I recently found,

0:02:45and this is the main story that I'm going to get into now,

0:02:49that it was never quite performant enough.

0:02:52It was never quite as fast as I would have liked it to be.

0:02:55It was never quite as stable as I would have liked it to be.

0:02:58And so I kept trying and working out ways to get around that.

0:03:03I kept adding different types of caching,

0:03:06taking the database and splitting it in two

0:03:08and having a read slave and a master,

0:03:10where all the writes happen, and all these types of tricks

0:03:13that I was kind of heading towards.

0:03:15What I found, though, is that that

0:03:18all kinds of other problems with it.

0:03:20And so here comes the story part of this.

0:03:22So last week, Reader 2 launched, which I highly recommend.

0:03:27It's an excellent app.

0:03:28I was beta testing it for a long time,

0:03:30and Silvio did a really good job of building it.

0:03:33And it feels right at home on iOS 7.

0:03:34It's really sort of slick and has some cool, nice touches.

0:03:38And I really like it.

0:03:40And I was actually really excited when it launched,

0:03:43because it has a lot of features that people

0:03:46have been asking for.

0:03:47has full support for feed wrangler,

0:03:48it has smart stream support.

0:03:50It does a lot of things that I was really excited about.

0:03:52One thing I did not anticipate, however,

0:03:54which is perhaps a little bit of foolishness on my side,

0:03:57is that it was launched as a new app.

0:03:59And so everybody who uses it, which

0:04:02is a pretty high proportion of my user base,

0:04:05bought it and then proceeded to resync their entire article

0:04:10lists into it, which meant that my already kind of--

0:04:16A little bit on the edge, not a lot of headroom server infrastructure was completely crushed

0:04:20and destroyed.

0:04:21And so last Wednesday, I believe it was when it launched, all of a sudden things just went

0:04:26from bad to worse.

0:04:27And the things that I had been kind of scraping by with and my patches and sort of intermediate

0:04:33solutions had been working, but were not working well enough at this point, without amount

0:04:40of traffic, where I think I was going to something about two or three times at least normal traffic

0:04:45load, and especially the kind of traffic that it was, was very--

0:04:49was much more difficult to deal with than normal traffic.

0:04:52Because normal traffic, most applications

0:04:54are only asking for recent things.

0:04:56They're asking for, what are the new articles

0:04:58since a particular time?

0:05:00Whereas now, when you do a full sync, you kind of go back

0:05:04and go, OK, what are the articles they have,

0:05:07so sort of a week ago or a month ago, depending on the client.

0:05:10And you're kind of going this far more back,

0:05:13this deep, backward search.

0:05:14And so that's very hard from a caching perspective to deal with, because rather than dealing

0:05:18with the normal working set, you're dealing with essentially just an approximation of

0:05:23the entire working set of the database, which is 200 gigabytes, which is too large to reasonably

0:05:28be caching.

0:05:29And so everything just kind of fell apart.

0:05:32And so I arrived at the place of then having to try and deal with, well, what do I do with

0:05:40this?

0:05:41What can I do?

0:05:42do I keep trying to solve this the way that I have,

0:05:47with introducing new levels of caching,

0:05:50new levels of complexity,

0:05:52splitting traffic in different and interesting ways,

0:05:54or should I really just sort of do what I probably

0:05:57should have done from the start,

0:05:58and that is kind of throw money at the problem,

0:06:00is one way to say it.

0:06:02And I'm gonna kind of get into it a little bit later,

0:06:03but the main lesson that I've been,

0:06:06as I've been trying to boil down my experience

0:06:07over the last couple of days,

0:06:09is into sort of like an aphorism,

0:06:11I was going to try and put it concisely, is that the lesson I think I've learned is that

0:06:15I should try to avoid to solve with cleverness that which I could solve with money.

0:06:21And by that I mean I've recently gone through the process of migrating the entire feed wrangler

0:06:26back end to dedicated bare metal, ridiculously fast machines that are hosted, I host them

0:06:34with soft layer, but it's basically I'm literally buying a server that's incredibly beefy, you

0:06:40know, super fast, big SSD drives in a RAID configuration, the dual processing, big Xeon

0:06:47chips.

0:06:48Like, it is a beefy, beefy machine.

0:06:50And it certainly cost more than what I was paying at Linode, but it means that my performance

0:06:54now is being-- essentially, my performance problem is being solved by just spending a

0:07:00lot more on the server.

0:07:02And the experience of going through this process has been kind of interesting, and I'll talk

0:07:07about that now.

0:07:08And it's also just--

0:07:09I really think I've learned a lot of things

0:07:11by going through this.

0:07:12So the process was essentially--

0:07:14so on Wednesday, the entire system just

0:07:17started grinding to a halt. Like,

0:07:18my error rates were getting really high,

0:07:20and just things were going crazy.

0:07:22If you're familiar with the load parameter,

0:07:25if you type top on any Unix or Linux machine,

0:07:28you can get a load parameter.

0:07:29And every now and then, my databases

0:07:31were spiking to loads of like 20 or 30,

0:07:34which is completely insane and definitely not what you want.

0:07:36You want to load to probably be between 0 and the number of cores

0:07:41on your machine at most.

0:07:42So you're at least nowhere higher than at least 8.

0:07:458's still pretty high, but you don't want

0:07:47to be nowhere up in here, 20 or 30.

0:07:50And so my I/O was just really crushed.

0:07:54It was essentially running at 100% utilization the entire time.

0:07:57And so I started looking at my options.

0:07:59The first thing I thought about is, OK, is it just

0:08:01because Linux doesn't have SSDs?

0:08:04So I started looking at DigitalOcean, which is another VPS provider, which does have the SSD.

0:08:09And so I took my database, replicated it over there, tried it out.

0:08:13And the reality was it was a little bit faster, but it was a marginal improvement.

0:08:17And at this point I just started to think about, "Well, you know what I need to do?

0:08:22I think I just need to try it. What is the most performant thing that I could possibly do?"

0:08:25And that sort of led me to just deciding that, "You know what I need to do?

0:08:30to do, I'm just going to put this on a dedicated host.

0:08:32And so I've since, in the last few days,

0:08:35over the course of, I think it was three sort of sleepless

0:08:38nights doing this all between 2 and 5 in the morning,

0:08:42so that it has the least impact on customers.

0:08:45The reality is the thing was barely holding together

0:08:48as it was, so I suppose I could have done it

0:08:50in the middle of the day in some ways.

0:08:51But through a lot of sleepless nights,

0:08:53I was able to take the entire infrastructure that

0:08:56was currently on Linode and has now

0:08:58been migrated onto bare metal servers at SoftLayer.

0:09:03And that process, I will say, is a little bit insane,

0:09:06and it's something that I hope to not have to do again.

0:09:08It's kind of, the best analogy I can think for it

0:09:11is it's like changing the wheel in your car

0:09:14while you're driving it.

0:09:15'Cause you're trying to move these things

0:09:18and migrate them over while still dealing

0:09:20with all the incoming traffic.

0:09:21And so it was a little bit crazy and a little bit hectic,

0:09:24but thankfully it's done now.

0:09:25This is, I think, Tuesday, and so as of yesterday,

0:09:27about Monday morning, I did the last transitions,

0:09:32and other than some lingering traffic

0:09:35that still hasn't updated its DNS,

0:09:37everything's now hitting the soft layer stuff,

0:09:41and it's blazing.

0:09:43It's kind of remarkable.

0:09:44And at first, I wasn't even really sure what to expect

0:09:46when I went to this new server,

0:09:49but the reality is it's been incredibly faster.

0:09:51Not just a little bit, not like, "Oh, yeah,

0:09:53it's a 20%, 30% improvement."

0:09:53Everything is at least two to five times faster.

0:09:56And many operations are 10 times faster than they were.

0:09:59And they're much more consistent, too,

0:10:01which is even probably the more important thing.

0:10:03Because even if it was the same speed as it had been before,

0:10:06but the variance between different operations

0:10:11was better, I would have been happy.

0:10:13But it's both faster and more consistent.

0:10:15And I love being able to see this objectively, where

0:10:18I was looking at my server stats for this.

0:10:21And I was able to see that my typical response times before,

0:10:25like my overall average response time for all requests,

0:10:27was somewhere around 750 milliseconds to one second

0:10:31before.

0:10:33And as of right now, it's consistently

0:10:36around 200 milliseconds, and often even as low

0:10:39as 150 milliseconds.

0:10:41So that's about a five times improvement

0:10:44or so in response time.

0:10:46And that's average, so certainly some things are slower

0:10:48and some things are faster.

0:10:49That really means that a lot of things are much, much faster than they were before.

0:10:53And so that's the experience that I've had.

0:10:55And I think it's interesting as a broader lesson to understand that if there are things

0:11:00that you can do, it's very easy, I think, in the heat of the moment to be sort of pennywise

0:11:06and pound foolish, where I was looking at hosting at Linode as kind of a good option

0:11:12because it sort of did what I wanted, and it had close enough performance characteristics

0:11:18that it was possible. But the reality was the amount of time that I've probably spent

0:11:23in the last three or four months working on performance issues and tuning and caching

0:11:27and dealing with all these kinds of issues that would have completely gone away if I

0:11:31had just decided to start off investing the money and the resources into just taking,

0:11:39sort of letting the hardware solve the problem for me, I think the product would have been

0:11:43better. And that's sort of the tragedy of this. And that's why I wanted to kind of have

0:11:47an episode talking about this experience, is that making sure that when you're spending

0:11:53time on something, understanding whether that time could be better spent doing something

0:11:57else, and if you could outsource that need to something that you can solve with money,

0:12:05or with resources and whatever that looks like. And it's a funny thing to say, in some

0:12:08ways, to say that, "Well, what if you can't afford it?" Well, the reality is if you're

0:12:13you're spending your time on something that's sort of the-- if spending time, your own time,

0:12:19is the alternative, then the real question is, you know, can you afford that time? Because time is

0:12:23even more valuable than-- or much more constrained and limited, often, than money is. And so looking

0:12:30into ways to avoid spending time when you can solve it with money is very important. And it's

0:12:35like I really-- I also fell into the trap, I think, as an engineer, of thinking that the-- in some

0:12:42is I'd be cheating, or it's like, oh, I'd be a copping out

0:12:47or whatever if I didn't solve these problems with technology.

0:12:52If I wasn't being super clever, and I kept being like, oh, what if I did this?

0:12:57What if I did that? And I kept viewing it as this engineering problem.

0:13:02When the reality is there was a solution and a way to avoid it, to address this problem that didn't require cleverness.

0:13:08that wasn't about how smart I was,

0:13:13and it wasn't this problem that I needed to solve.

0:13:15I could just say, "You know what?

0:13:17I know it's like I can just move this to something

0:13:19where it'll be much, much, much better."

0:13:23And that's just something, it's exactly what that means,

0:13:25and the implications that might be for yourself

0:13:28and your own applications are certainly going to be different.

0:13:30It's, are you solving, would it be better to outsource

0:13:34a particular part of it to an expert in the field?

0:13:34Is there a part of your business that you

0:13:35can outsource in that way?

0:13:37Are there things that you're spending a lot of time on that

0:13:40could be solved in another way?

0:13:43And so the lesson that I've learned from this,

0:13:45and the thing that I've taken away,

0:13:46is that, A, it's hard to move servers.

0:13:49Mind the lesson.

0:13:51But the more important thing is, don't solve with cleverness

0:13:53that which you can solve with money, with resources.

0:13:57And so that's kind of the experience that I've had.

0:13:59And it's really exciting now.

0:14:01When I look at Feed Wrangler, I'm

0:14:02really excited about some of the things

0:14:03that I can do with it and with PodWrangler,

0:14:06and being ready for PodWrangler's launch

0:14:08in a different way, that I'm-- I've got tremendous amounts

0:14:10of headroom on my servers now that I can grow and play with

0:14:13and use that I just didn't have before.

0:14:15And so I'm excited about that.

0:14:17And I think that's ultimately the biggest plus,

0:14:19is that I can focus on my apps.

0:14:20I can focus on my user experience.

0:14:22I can focus on things that people will notice and enjoy

0:14:26in a way that I couldn't when I spent so much time and energy

0:14:29focused on making things just run in the first place.

0:14:32And so that's my experience.

0:14:34That's been my last couple of days.

0:14:35It's been a little rough, but I got through it.

0:14:37And I think I've learned some things from it, which I'll

0:14:39hopefully be able to implement in the future.

0:14:40And anyway, that's it for today's show.

0:14:42As always, if you have questions, comments,

0:14:43concerns, complaints, I'm on Twitter

0:14:45@_davidsmith, david@developingprospective.com.

0:14:47Otherwise, if you have a great week, enjoy your new iPhones,

0:14:50enjoy your new iOSes.

0:14:51And I'll talk to you guys next week.

0:14:53Bye.