News for hackers. Stuff that matters.
Re:Microservices – Not a free lunch by DanielBMarkham on Sunday December 28, 2014 @06:35AM (#8806039)
I'm really happy to see DevOps, CD, and Microservices take off, although, as usual, I'm a little perplexed as to why we need new slang. But hey, if it works to get the message out, I'm all for it.

These things are not new, but like so many other ideas, they're just old ideas re-appearing in a context that had forgotten about them.

Traditionally, many of the potential problems the author relates have been solved by architectural conceits. For instance, standardize on a programming language and datastore, then share all persistence-related files. (I'd strongly suggest a FP language, preferably used in a pure manner). Then you've decreased the "plumbing" issues by a couple orders of magnitude, lowered the skill bar for bringing in new programmers, and you can start talking about using some common testing paradigms to work on the other issues.

I'm a huge fan of microservices, but it's good to talk about the bad parts too, lest the hype overrun the reality.

Re:Microservices – Not a free lunch by waps on Sunday December 28, 2014 @07:17AM (#8806105)
It's just a technology cycle. Microservices have serious disadvantages as well, which will cause their elimination in, oh, 5 years if they're lucky.

1) They're not really simple. If you take essential functions like a key-value store, that'd be a microservice. Simple ? Yeah right. Business logic ... simple ? Yeah right.

2) It's slower. You can wine all you want, but when it comes right down to it, there's a reason people avoid crossing the network, and the microservice approach essentially comes close to crossing the network every single time you cross module boundaries. You'll be spending 50%+ of your cpu time marshalling and unmarshalling and waiting for transmission, even on the same system.

This also manifests in all these "no-sql" datastores. They have all the problems of sql datastores, but they have one more. There's no way to have indexes. So in a table indexing all your sales by "id", the only way to find sales of product "X" is by going through each and every record (you can build indexes yourself, but it's not easy and it's sure as hell not flexible. Plus I guarantee you'll do it wrong the first 10 times). This means that retrieving 10 sales records takes the exact same amount of time as generating the yearly sales reports. In other words : you won't be doing it, because it takes too long.

3) There's just so damn many of them if you want to achieve anything useful. Every single one of them needs to be sufficiently well-designed to operate like an individual web server. So (d)dos-resistance, fairness, anti-slowloris, anti-starvation, autoscaling, resource exhaustion (like maximum number of file descriptors ...) correct sharding, access control (not too tight, not too loose, ... correct caching of security credentials, ...), and load testing, you've thought of all that for that "really small and dumb" service that basically copies information across the payment/non-payment firewall right ? If you haven't ... prepare to be surprised.

A related problem here is the shear amount of diagnostic monitoring you'll need.

4) They are inflexible, and don't deal well with different data types (this is one of the things object oriented programming solved). They work well when they deal with strings, or with company-standard datatypes. Only companies don't like to have company-wide standards. Yeah, I know Sun and to a lesser extent Facebook succeed at it, but does your company ? Last time I consulted at a bank they had systems interoperating using every interchange format from fixed-width fields (old cobol code), 5 different kinds of xml, and of course json and a dozen binary formats. Microservices can't work in such an environment. It destroys the flexibility of individual actors. The argument here, of course, is that that is a good thing, and I'd say you're right, but you've just created yourself a hell of a lot of enemies, some of them powerful.

5) It's extremely hard to orchestrate integration across multiple microservices. The first thing this will manifest in is testing. How do I test one service ? The answer is "unit tests" or "a system test". But this is the result of a fundamental misunderstanding. As a company, or even an IT department, you don't really care if unit tests and/or system tests succeed for a microservice. You care that if you connect a -> b -> c -> d -> e -> f -> g (and usually this is a network of microservices, not a sequence) that you can sell gizmos on your website.

Testing if that works requires throwing up three dozen services. Now first, having watched the netflix talks, they do this. Congrats. That's can't be easy. They also talk about the disadvantages : they have 3 teams doing nothing other that making that work, and it eats a significant part of their AWS resources. They can't do it on developer's workstations, nor even on a number of them.

The second thing this will manifest in is the cross-microservice redesign. Say a new law comes in. With a payment we now need to have a scan of the driver's licence of the buyer (say "gizmos" are treated like alcohol). So we simply need an extra image field going through the payment system. Oh-oh. The payment system is 8 microservices, and therefore around 64 interfaces to the rest of the system. Let's be generous ... only about 30 need to be redesigned. There is nothing to help. Refactoring, or even type checking doesn't work across microservice boundaries.

This presents 2 problems.

First is that it's a hell of a lot of work, even though most services only do basic things and don't care about the new data. But they still copy the data, save it, ... each of them needs logic to deal with missing data (historical data for instance), and the copy from one json dict to another needs to be implemented. And as you'll find every microservice has it's own methods for dealing with said datatype, you'll be checking up to 8 libraries for marshalling problems.

Second is testing. Any error you make won't come up unless you're testing multiple of those services simultaneously. If you manage to have just a bit more complexity in your system, those problems won't come out until the massive full-system integration test. You know, the one you can't do yourself, and even your whole department can't do. Oh-oh. That's an awfully long feedback loop to find those 3 dozen places where you forgot to copy that field across.

Re:Microservices – Not a free lunch by DanielBMarkham on Sunday December 28, 2014 @08:18AM (#8806187)
Your comment was in some ways better than the original article! Thanks.

But, as you know, many of these problems are either solved or non-existent in Big-Monolithic-App-land.

So -- take the things that worked there and use them. Like I said, a common set of shared source code that handles all persistence means all apps can talk to each other using the same code. Changes don't break the chain. Stuff can be fixed in one spot. And so on.

The orchestration and testing pieces deserve special attention. I think you're going to end up with as many folks writing test/monitor/break code as you are microswervices. And that's probably a good thing. But you need to plan for that.

As far as the hype cycle, I've seen this over and over again. As far as I can tell, the driver is over-specialization of developers. Some new buzzword comes out, people teach and train around that, and suddenly you've got somebody called a "DBA" that can't write a web service. So then you need a "Front-end" guy, and so on. This industry is constantly labeling things, over-developing them, creating work silos that lead to poor performance, then going back and relabeling things again. There's some magic number of developers where you need specialists, but it's not 10, or even 40. The longer you put off creating silos, the better the entire effort is.

EDIT: In fact, I'll just say it: if you want to swim in the ocean of nirvana that is microservices, use pure FP and share all the source code that involves persistence.

Re:Microservices – Not a free lunch by parasubvert on Sunday December 28, 2014 @01:04PM (#8806855)
There's been a drive towards "full stack developers" lately: http://www.laurencegellert.com/2012/08/what-is-a-full-stack-...

That said, most of human history has involved specialization, modularity, and abstraction driving greater productivity.

So on one hand, you have work-silos, on the other you have the power of modularity. I think difference with software is that most of the productivity constraints happen at the interfaces. Teams need people that can integrate. They can be generalists, or specialists in a few areas.

Earlier in your post you suggest:

"But, as you know, many of these problems are either solved or non-existent in Big-Monolithic-App-land. So -- take the things that worked there and use them. Like I said, a common set of shared source code that handles all persistence means all apps can talk to each other using the same code. Changes don't break the chain. Stuff can be fixed in one spot. And so on."

IME, multiple teams using the same library can be helpful (if voluntary) or a complete disaster (if forced). The incentives of the library maintainers are not always that of every team.

Re:Microservices – Not a free lunch by caw on Sunday December 28, 2014 @08:45AM (#8806239)
> Oh-oh. The payment system is 8 microservices, and therefore around 64 interfaces to the rest of the system.

Up until now I've been operating under the assumption that "payments" separated out from the app is microservice, and it didn't need to be subdivided further. Your comment seems to imply this is still too monolithic for the microservice buzzword?

Could you provide an example microservice payments architecture?

Re:Microservices – Not a free lunch by jn on Sunday December 28, 2014 @08:59AM (#8806267)
> in all these "no-sql" datastores [...] there's no way to have indexes

I'm confused. I assume http://docs.mongodb.org/manual/indexes/ doesn't cover what you mean by indexes?

Re:Microservices – Not a free lunch by marktangotango on Sunday December 28, 2014 @12:17PM (#8806719)
You are correct, the parent made a broad generalization that's not true. Mongodb indexes represent the sitaution though, in a schemaless environment, what is the meaning of an index on a collection heterogenuous records? If the system enforces that the indexed fields are always present (either the app or the nosql store) then hmmm isn't that a schema?

The other issues is joins across record types sometimes joins are supported, sometimes not.

Re:Microservices – Not a free lunch by parasubvert on Sunday December 28, 2014 @12:52PM (#8806827)
I think you bring up a lot of good points, though I'm a bit more optimistic about the trend.

>2) ".... there's a reason people avoid crossing the network, and the microservice approach essentially comes close to crossing the network every single time you cross module boundaries."

We've been trying as an industry to cross the network efficiently for decades. Ultimately it comes down to team structure. Microservices presumes its easier to scale an organization to run/evolve their teams/modules independently from other teams/modules, communicating over a network interface, than "stopping the world" to integrate a monolith or "enforcing a standard across the company" beyond the subset of published language required to make communication work.

Whether that's a reasonable tradeoff generally depends on the performance needs between the modules.

>3) ".... Every single one of them needs to be sufficiently well-designed to operate like an individual web server. So (d)dos-resistance, fairness, anti-slowloris, anti-starvation, autoscaling, resource exhaustion (like maximum number of file descriptors ...) correct sharding, access control (not too tight, not too loose, ... correct caching of security credentials, ...), and load testing, you've thought of all that for that "really small and dumb" service that basically copies information across the payment/non-payment firewall right ? If you haven't ... prepare to be surprised."

I agree. But there are plenty of examples of how to bake that in to each service for reasonable cost - the Netflix OSS services, for example, the emerging platforms like CloudFoundry that give you the resource isolation + access control + scaling + etc. There's no excuse to fail to analyze what's out there and pick an appropriate set to cover these areas.

4) "Last time I consulted at a bank they had systems interoperating using every interchange format from fixed-width fields (old cobol code), 5 different kinds of xml, and of course json and a dozen binary formats. Microservices can't work in such an environment."

Okay I don't really understand this one. Are you suggesting that every micro service should be able to parse all these different formats and semantics? If I needed a micro service that spoke several different languages, I'd probably include some kind of integration library to do such a thing (say Spring integration).

If I wanted to incorporate legacy systems into a new micro service app overall, I'd probably form a micro service that wraps it in a bubble, depending on the circumstances. e.g. http://domainlanguage.com/newsletter/2011-06/

If you look at how Netflix migrated from Oracle / SimpleDB to Cassandra, this latter approach is how they did it (though it was more of a synchronization service than just a bubble, since it was intended to shut off the old system eventually).

5) I agree, the tools for testing and test data replication in the enterprise aren't up to what Netflix pulls off - they rely on the broad facilities of Cassandra and S3 to be able to quickly replicate test data to a cluster.

However, do you have a link for where Netflix says they have 3 teams doing this work? I think this may be open to misinterpretation, because my understanding is that their development teams basically deploy into production - they don't do full integration tests, the canary deploys basically catch boneheaded changes - and there's certainly a lot of A/B testing.

There are testing teams, but they aren't the usual sort: they're building processes to do device testing, "failure injection testing", introducing chaos into the production system. It's just a very different approach to the usual "stop the world and test everything" we see in the enterprise.

"So we simply need an extra image field going through the payment system. Oh-oh. The payment system is 8 microservices, and therefore around 64 interfaces to the rest of the system. Let's be generous ... only about 30 need to be redesigned. There is nothing to help. Refactoring, or even type checking doesn't work across microservice boundaries."

This strikes me as hyperbole. If you take the adage of "team = microservice", you're implying 8 teams manage the payment system. That doesn't smell right.

Secondly, the biggest barrier to adding new fields IME in distributed systems are overly locked down interfaces. If the interfaces allow for extensibility, adding a field, even across eight micro-servcies, takes almost no time at all. I've seen this in a deep system with 4-layer service chain. We had to add a field to the GUI for the next (2 week) iteration, this required prioritization and coordination across 5 teams, one of which was a COBOL/MQ system -- but ultimately took maybe a few days because the interfaces through the chain were designed to be extensible (and the copy book had room for an extra field).

> " Any error you make won't come up unless you're testing multiple of those services simultaneously. If you manage to have just a bit more complexity in your system, those problems won't come out until the massive full-system integration test. You know, the one you can't do yourself, and even your whole department can't do. Oh-oh. That's an awfully long feedback loop to find those 3 dozen places where you forgot to copy that field across."

If the lesson here is that "most organizations are mediocre", you'll get no argument here.

If the lesson is supposed to be "there's a better way", I'm curious what it is. Is compile time type checking and refactoring monolithic software that's managed by 8 different teams is somehow better? I doubt it.

If anything the microservices approach makes it so that each team's service is evolving independently in production, and the system isn't going down or stopping while we all add this field independently across the teams. There is no "massive full system integration test" in the usual sense, there's continuous testing and failure injection. The automated test for adding this field will eventually pass, but there's no stopping the world to wait for it.

Re:Microservices – Not a free lunch by caoilte on Sunday December 28, 2014 @12:39PM (#8806795)
Those are well articulated problems that people working with Microservices are very concerned with solving. I agree that there is a technology hype-cycle but I think what actually tends to happen is that the best parts of existing solutions (eg in this instance "SOA") get re-thought from the ground up. Each time we keep more and I think Microservices are a step forward in many ways.

Taking your individual points in turn,

1) A Microservice should wrap a business problem not a technical problem. So "A Key-Value store" should never be a microservice. They should aim to be swan-like - making the difficult look easy. ie they promote encapsulation of difficult business problems.

2) It's a fundamental tenet of distributed systems design that the parts of the system which need to be fast should be identified and their development treated accordingly. Microservices optimise other constraints. (You can still get blindingly fast speed where you can suffer eventual consistency - which is about 90% of the time for most businesses.)

3) Continuous Delivery says, "When your deployments are difficult and slow it means you should do more of them." Most Monoliths handle all of the problems you described very badly. If your business can scale the processes for handling them (which it needs to) then it doesn't matter if you have one service providing them or many microservices - you can still handle it.

4) I don't understand what you are saying (particularly the OO bit). I think you're implying that microservices require a utopian ideal that isn't possible inside large enterprises. There is nothing wrong with evolving towards the ideal. DDD gives you "anti-corruption layers" to handle interfaces that cannot evolve fast enough for systems that depend on them.

5 i) This is a big challenge and I think that best practices are still evolving in this area. Contract testing (see Pact for one implementation) helps a lot. In general the challenges here drive businesses towards fully automatable IaaS - and this is also a good thing. Once you can spin up an entire environment on demand you can do (a limited number of) full end-to-end tests to smoke test your system.

In general this is a problem for everyone, though, regardless. It's just most multi-monolith businesses don't deal with the limited number of problems introduced across system boundaries and either fix them post-deploy or spend weeks in UAT system configuration hell.

Also it's something we're increasingly going to have to learn how to handle better as developers as we employ more SaaS in what we use. The problems are very similar.

5 ii) If a data change requires changes to 30 microservices then something has gone very very wrong. There shouldn't be 30 microservices that need to be aware of the existence of a driving licence. It sounds like you're used to doing very explicit marshalling. Coast-to-Coast marshalling can help here. Most microservices should look at the data they are interested in and have strategies for ignoring the rest.

W/regard to new data / historical data - the elephant in the room that hasn't quite reached the broad industry acceptance of say Functional Programming is Event Sourcing. This is a great introduction to the concept by (naturally) Greg Young: https://www.youtube.com/watch?v=KXqrBySgX-s