News for hackers. Stuff that matters.
Re:Microservices? Please Don't by dsmithatx on Tuesday December 13, 2016 @11:08AM (#13167804)
I'd like to hear some background from the author on his situation(s). Personally my current company is over 100,000 employees. We have a few 100 developers and many stacks, web apps, mobile apps etc. Our API is essential and is currently a giant monolith written by devs who no longer work here.

Splitting API code into repos based on endpoints allows us to have small easy chunks to deal with. It also allows us to drop those into containers and monitor and scale much easier. It also means instead of one API team, other devs can easily pickup a small code base and make changes for their stuff and, submit a PR for the API team. ]]

This article seems a bit elementary to have been voted up high on HN to be honest. It failed to acknowledge the true merits of doing microservices properly and the huge gains. Not all code bases are meant for microservices. However, huge monolith API's in general are a very good example where it's a perfect fit.

Re:Microservices? Please Don't by StavrosK on Tuesday December 13, 2016 @11:42AM (#13168131)
Why can't you split up your code into libraries? API doesn't have to mean "HTTP API", you're free to pick a different IPC layer.
Re:Microservices? Please Don't by rubber_duck on Tuesday December 13, 2016 @12:52PM (#13168809)
The same reason you want to put stuff in to multiple processes: clear boundaries forcing separation and isolation, allowing you to use different technology stacks for different things, letting you limit access/allocate resources to specific parts of the app, etc.

I agree with regards to HTTP not being the only IPC layer but it's also the most commonly used and there is so much tooling built around it, everything speaks it - so I would say unless you have a good reason not to you should default to it.

Re:Microservices? Please Don't by mikeryan on Tuesday December 13, 2016 @01:15PM (#13169020)
We do both.

We have domain based services based on nodejs which tend to be smaller for example a content management service is separate from our notification service which is separate from our user authentication service which is actually provided by a third party (Auth0). In fact being able to use third party services in place of homegrown is one of the big benefits we've found of a microservice architecture. Particularly when creating prototypes and trial apps for clients. The goal is in initial launch we leverage third parties as much as we can then pull back and replace with internal services as we need.

But we also have a suite of npm modules which can be shared across the services for common tasks (our ORM models being a primary use case). Maintaining the libs can be a bit of a pain point and making sure we have solid tests is crucial to making sure we don't break other services but it works pretty well.

Re:Microservices? Please Don't by danudey on Tuesday December 13, 2016 @03:08PM (#13170443)
Not to mention that if you have hard, effectively physical boundaries between services (i.e. completely separate processes in completely separate projects) it makes it easier to scale them independently.

For example, when we started out we had a few servers running all of our stuff. When one service grew more, we scaled it out to its own services. Because we used Django's ORM, all of a given service's tables are restricted to a given prefixed schema (e.g. 'systemname_servicename'), which is easy to migrate separately to a new service without risking breaking interconnections ('oh, we have this one query that uses that one table') etc.

Re:Microservices? Please Don't by eej71 on Tuesday December 13, 2016 @11:45AM (#13168169)
I think the popular counterpoint has been - microservices _forces_ consideration of a good API because you are now on the network even if its just localhost.
Re:Microservices? Please Don't by falcolas on Tuesday December 13, 2016 @11:58AM (#13168301)
I'd counter that they also force a lot of additional networked API boilerplate, and all new code is a potential source of bugs.

Perhaps it's better to break it into libraries with well defined APIs, and then break those libraries out into services when necessary. Jumping straight to the latter is going to create more room for problems than it solves.

Re:Microservices? Please Don't by dsmithatx on Tuesday December 13, 2016 @12:22PM (#13168531)
Well we are rebuilding from scratch into micro services as we have the man power and money to do it. Why not just go with libraries? Here are the top five reasons off of the top my head.

The current monolith is requires vagrant and doesn't mimick production nearly as well as smaller containers.

This design will be easier to understand and with dev turnover that means bringing new devs up to speed faster. This is especially important when working with outside development firms which we do.

Deployments and scaling will be much faster. If one endpoint goes down it wont affect others. We are working to ensure one endpoint is not dependent on another.

When change is required in a certain part of the application, only the related service can be modified and redeployed.

No long-term commitment to a single technology stack

Re:Microservices? Please Don't by acdha on Tuesday December 13, 2016 @12:58PM (#13168871)
That sounds like most of the benefits you're describing simply due to redesigning the system with the benefit of experience and the much deeper knowledge about the problem which you learned building it the first time. Almost every point on your list could be restated in the opposite direction:

> The current monolith is requires vagrant and doesn't mimick production nearly as well as smaller containers.

The decision to require use has nothing to do with microservice/monolith and you'd get the same consistency benefits if you deployed a large single application in a container as well, plus you'd have the added simplicity and debugging benefits from not needing to run additional applications for things like orchestration or service discovery.

> This design will be easier to understand and with dev turnover that means bringing new devs up to speed faster. This is especially important when working with outside development firms which we do.

Easier to understand is an aesthetic choice but it generally means things like a clean design, organization, good documentation, etc. which can be done in a monolith as well. Smaller services can encourage that but they don't necessarily – I've seen plenty of gnarly interdependencies and under-documented schemas – and they have a hard up-front cost that now all of your new developers will need to be able to start, reload, and debug many separate services and understand any interdependencies. If your culture and tooling can manage that well, it almost certainly could maintain a clean larger codebase following the same principles.

> Deployments and scaling will be much faster. If one endpoint goes down it won't affect others. We are working to ensure one endpoint is not dependent on another.

This is certainly the appeal but many places find that the scaling benefits are less than predicted because the business logic requires things which are harder than expected to separate or scale independently, and there's a cost to separation if that means that you're now forced to implement something like distributed transactions or locking on top of your own custom services.

Again, I think a team with the experience and support which can do this well in one model is also likely to have similar results with the other.

> When change is required in a certain part of the application, only the related service can be modified and redeployed.

If you have a well-defined automated deployment process, this is a relatively minor benefit in either case. Assuming you weren't just running a single instance of the previous app, you need a way to handle things like blue-green deployment, managing schema updates, etc. no matter which design philosophy you pick.

> No long-term commitment to a single technology stack

This is one of the strongest arguments, but there is also a cost involved to having to learn and support multiple stacks. Again, I think that's more a function of culture and resources — I've seen places which were too conservative until they couldn't find developers at any price as well as places which had severe “Oooh, shiny” problems where every module was written in the latest thing the "lead" developer had seen that week.

Again, I'm not saying one approach is right or wrong but rather that it's too narrow a view to look at one practice in isolation. The microservice idea has been around for decades but it hasn't become universal because quality of implementation matters a lot and it's not optimal for all problems — I'm pretty sure the team at Oracle which built the deeply horrible business application I had to support about a decade ago used many of the same arguments to pitch the benefit of their enterprise Java web service architecture, which turned simple database queries into thousands of calls to services on a dozen servers. It's not that the concept was right or wrong but that it wasn't a silver bullet.

Re:Microservices? Please Don't by tekklloneer on Tuesday December 13, 2016 @12:49PM (#13168784)
This is like looking into a mirror.
Re:Microservices? Please Don't by flukus on Wednesday December 14, 2016 @01:48AM (#13174310)
I've also seen them be he source of some awful n+1 bugs where network boundaries were being crossed thousands of times to fetch some relatively simple data. The wall time might be tiny on it's own but it can add up.

I've also worked on an app where we removed/combined the api layer into the main web process for an instant 30% performance boost. Crossing the network boundary, serializing, etc was taking up a full third of the wall time that included server side html rendering and database access.

Re:Microservices? Please Don't by Chyzwar on Tuesday December 13, 2016 @06:16PM (#13172205)
But your networked API is language agnostic, your library is not.

It depends but microservices are in many cases better where your application is large. Examples: AWS, Uber.

Monolith is better if your application smaller and cover just single problem. Examples: Slack, Trello, Jira

Re:Microservices? Please Don't by mhluongo on Wednesday December 14, 2016 @01:28AM (#13174263)
I'm skeptical that Slack is in the "better as a monolith" category considering the message volume they must process
Re:Microservices? Please Don't by flukus on Wednesday December 14, 2016 @06:02PM (#13180565)
Microservices don't solve the volume problem, a monolith can have multiple to deployments to handle volume.
Re:Microservices? Please Don't by acdha on Tuesday December 13, 2016 @12:26PM (#13168578)
I think those issues are orthogonal: if the environment wouldn't discourage a hasty library API, it seems unlikely that it would discourage a similarly-poor network service.

The part I would try to focus on is the culture for things like review and what your threshold is for treating something as a reusable service rather than an internal detail for one app.

Re:Microservices? Please Don't by maxxxxx on Tuesday December 13, 2016 @06:20PM (#13172233)
I think if you are not capable of designing a decent API you won't be able to design good microservices either. Both require some level of competence and discipline.
Re:Microservices? Please Don't by djsumdog on Tuesday December 13, 2016 @12:18PM (#13168497)
Unless you have a system to show when all your project have out of date libraries (both local jars that own own and remote dependencies), this can grow to be maintainable. Even with REST enpoints you still often have "client libraries" that need to be updated to take advantage of new functions.

If you're not careful with dependencies and coupling, you can get into situations where you can't upgrade a service without touching n other services; and you have to be sure to deploy them in order.

Re:Microservices? Please Don't by UK-AL on Tuesday December 13, 2016 @12:22PM (#13168534)
"If you're not careful with dependencies and coupling, you can get into situations where you can't upgrade a service without touching n other services; and you have to be sure to deploy them in order. " Why aren't you versioning your api?
Re:Microservices? Please Don't by jose_zap on Tuesday December 13, 2016 @02:21PM (#13169846)
How does versioning an API solve the problem of having to deploy interdependent services in the right order? For a change involving two services that need changing, Service A calling Service B, you still need to deploy B before A.
Re:Microservices? Please Don't by UK-AL on Tuesday December 13, 2016 @02:45PM (#13170177)
Because you obviously need to add that feature to service b before anyone can use it. This goes for anything in software, libraries, products, APIs etc.

Ideally that feature should be developed indepedently by the team looking after that service. It could however be a feature request by another team.

Once the feature is ready, you deploy it and then advertise this feature is now available. If it's a breaking change, you version it so it doesn't effect existing services.

Then the team for service a can now start integrating that feature into their service.

You don't need complicated orchestrated deployments. The time from service/team b advertising that the feature is available, to service a acutally consuming it may be weeks.

You just treat the microservices as separate products exposing a API, which operate on different timelines. Other teams may request features, but the team maintaining the service determine the how and the timeline. Obviously higher priority items get developed first.

Re:Microservices? Please Don't by lostapathy on Tuesday December 13, 2016 @03:02PM (#13170371)
When the API is versioned (and you keep both versions online), you can deploy the update to service B long ahead of when service A needs deployed
Re:Microservices? Please Don't by djsumdog on Tuesday December 13, 2016 @06:14PM (#13172188)
We do version API. Everything is done by content type. You can ask for a "vnd.something.something.json+v1" "+v2" etc...you still want to update everything on the older version so you don't want to maintain that crap forever.

Then there's the splunk searches you have to run to make sure all your consumers are onto the new version .. and that "What the hell is that IP and why is it using v1? Why does this API key not have a name on it?!"

Re:Microservices? Please Don't by bpicolo on Tuesday December 13, 2016 @11:57AM (#13168290)
If you do that your testing and deployment stacks remain monolithic, running tests / deploying becomes increasingly slower and more expensive. With a lot of developers on a big app and good CI practices a company might spend hundreds/thousands of compute dollars a day just running tests for one monolithic app.
Re:Microservices? Please Don't by eropple on Tuesday December 13, 2016 @12:18PM (#13168492)
Why does one imply the other? I regularly build applications out of composable libraries that are wired together with bog-standard dependency injection systems and each separate library handles its own testing and can be kicked off in its own CI process.

(I could even add in the boilerplate and performance hit of microservices, if I wanted to--just launch each library with its own thin HTTP layer. But I don't and don't need to.)

Re:Microservices? Please Don't by StabbyCutyou on Tuesday December 13, 2016 @01:32PM (#13169250)
Hi, original author here!

Quickly, on the "elementary" nature of the post, this was adapted from a lightning talk I gave, and so it was sort of designed to be a very quick introduction into the problem space.

Also this was meant to be (and this is my own fault for maybe not more carefully spelling this out) aimed at people just starting out with a new project or endeavor, as a warning that "just sprinkling some microservices on it" is not a magical panacea for scalability or good software design.

Thanks for taking the time to read and comment!

Re:Microservices? Please Don't by blauditore on Tuesday December 13, 2016 @11:50AM (#13168222)
The article's author description points to a startup company with a handful of devs, so it's quite likely that they indeed wouldn't gain much from microservices.

But large companies with large code bases are a whole different story, and what works well for the former might be unfeasible for the latter.

Re:Microservices? Please Don't by mikeryan on Tuesday December 13, 2016 @02:05PM (#13169674)
So as a small company or startup the upside of microservices is the architecture lends itself well to the use of third party services. Using Auth0 for user auth is awesome for not having to right a ton of user management boilerplate. Content ful for CMS capabilities gives you a content management system and UI. Firebase for DB and push services, Amazon SNS for notifications.

A lot of early prototyping and startup tasks can be done gluing together third party services while you focus on core product offering. You can always pull back services as you outgrow these. I think this use case is one of the huge reasons microservice architectures have been so popular.

Re:Microservices? Please Don't by bmh100 on Tuesday December 13, 2016 @05:51PM (#13171992)
The author addresses building internal software as monolith vs. microservices, not the use of others' services as part of one's monolith/microservice.
Re:Microservices? Please Don't by StabbyCutyou on Tuesday December 13, 2016 @02:27PM (#13169926)
This is more of the intended audience (earlier startups or smaller groups of devs), but I could have done a better job spelling that out.
Re:Microservices? Please Don't by Johnny555 on Tuesday December 13, 2016 @03:09PM (#13170456)
A company of 100,000 with 100 developers does not make high level architectural decisions from a blog (at least, it should not). If you read the article and can't identify exactly why the issues he raised don't apply to your organization's architecture, then it probably does apply to you.

The author did address your situation and said to use microservices:

“When you’re ready as an engineering organization.”

But for most smaller companies, the issues raised by the article are significant -- One company I worked at tried to do microservices and found that doing distributed transactions across multiple microservices was causing much more complexity than the microservices saved. Doing nested/recursive transactions and rollbacks across multiple services was causing multiple problems - especially in deadlock detection/avoidance. They eventually moved much of the code to a more monolithic service.

Re:Microservices? Please Don't by Retric on Tuesday December 13, 2016 @11:25AM (#13167984)
While breaking up a giant API is reasonable. Microservices are tiny, so you and the author may be talking about different things.

What % of your services consist of less than 100 lines of code? 1,000? 10,000?

PS: Nanoservices are often used as the negative extreme, but as Microservices have a rather fluid definition people are not always on the same page.

Re:Microservices? Please Don't by mabbo on Tuesday December 13, 2016 @11:41AM (#13168124)
The big advantage of microservices, imho, isn't that their code is small (though that can be true), it's that their domain is small. If it takes 100,000 lines to manage your user logins, then do so, but put it behind a simple API that the rest of the company can use.

Now you've freed yourself doubly- everyone else can just trust that logins work, and the team focusing on logins can focus on just that one thing.

Re:Microservices? Please Don't by awj on Tuesday December 13, 2016 @12:32PM (#13168632)
If it takes 100k LOC to manage your user logins, I doubt you can really put it behind a "simple" API. You're still going to have intricate details that everyone needs to know, but now you're adding all of the issues of networked communication and (often) allowing teams to use different languages/stacks/etc which prohibit inspection to understand the system they're calling.
Re:Microservices? Please Don't by mabbo on Tuesday December 13, 2016 @07:05PM (#13172585)
So break that logic up into smaller services yet, again splitting up the domain into smaller pieces. No one said a microservice can't call another microservice!

Logins are a bad example because it really shouldn't take 100k lines to handle it, but replace 'logins' with any business domain logic that you need.

And honestly, the biggest challenge often is building the simplest API possible without limiting your clients.

Re:Microservices? Please Don't by Retric on Tuesday December 13, 2016 @12:06PM (#13168367)
The problem is if you need 100,000 lines of code for your login you can probably break that up. EX: Employee login vs. contractor login.

So, where you might think microservices others may be thinking of your monolithic login service.

Re:Microservices? Please Don't by Jtsummers on Tuesday December 13, 2016 @12:19PM (#13168502)
Perhaps the focus should be on how people interact with the services.

If everyone interacts with the login service through the same interfaces, then they don't need to know how it breaks out internally or care.

If, however, you use it through one set of API features, and I use it through another very disconnected set, then perhaps it's time to break it down further.

At the end of the day, though, what does it contain? A list of users, their roles, and access control mechanisms. Does it make sense to have unified logins or multiple sets of logins across your company's services? If the latter, break it down to be run once per other application with specialised selection of features per application. If the former, let the login team handle control of the system and leave it a 100k monolith or break it down as they see fit.

Re:Microservices? Please Don't by falcolas on Tuesday December 13, 2016 @11:59AM (#13168315)
Each 100 LOC nanoservice is frequently backed by a 1,000+ LOC framework, so you're not really saving that much on code.
Re:Microservices? Please Don't by nasmorn on Tuesday December 13, 2016 @03:29PM (#13170646)
I would say that he fact that you have 100s of developers changes a lot. But I see micro services pushed as the default approach even for startups with 4 guys in a room.
Re:Microservices? Please Don't by collyw on Wednesday December 14, 2016 @08:09AM (#13175662)
You will have smaller easier chunks of code to deal with, but far more complex deployment and testing.