News for hackers. Stuff that matters.
Re:The End of Microservices by lobster_johnson on Thursday July 21, 2016 @01:15AM (#12134881)
I see several people criticize microservices here. We've been doing it for about 6 years and are extremely happy with it.

A core principle which a lot of people and articles ignore, though, is reusability. I bring this up on HN every time there's a discussion about microservices, yet I've never seen any discussion about it.

Essentially, you build out the backend to act as a library for your front end. So we have login, storage, analytics, reporting, logging, data integrations, various forms of messaging, business-structural stuff, etc. etc. all bundled up as separate services. The front ends just use these services to build a coherent product. The front end is the monolith: The microservices are the cloud.

For example, let's say I wanted to create a new product called "Hacker News". I'd use our storage service to store links and comments. I'd use the login service to let users log in. I'd use our messaging service to send notifications about things like verifying your email or send password resets. I'd use our analytics backend to emit events for reporting. And so on. I could easily build the whole thing without writing a single line of backend code, and without setting up a new cluster, because every backend service has been designed with multitenancy from the start.

This ability to piggyback on a platform of services where I think the real utility of microservices lies. Everything else — fine-grained scalability, smaller surface for tests, language-independence, swappable implementations, etc. etc. — are secondary to that.

Re:The End of Microservices by lmm on Thursday July 21, 2016 @04:49AM (#12135583)
Separate pieces of functionality into small reusable libraries? Great. Enforce separation of each library's internals from each other one? Great. Ensure each database is owned by one and only one service? Great.

Invoke those services via RPC-over-HTTP? Why???

Re:The End of Microservices by krisdol on Thursday July 21, 2016 @11:53AM (#12137660)
>Invoke those services via RPC-over-HTTP? Why???

I can think of a few off the top of my head:

1. Being able to scale individual, smaller components rather than one giant application

2. Being able to build-and-deploy any one module much faster than one monolithic bundle of local dependencies

3. Universal interface with language-agnostic applications. Do you need to expose big data statistical analytics, but can't find data engineers that are comfortable with Java/Node.js/Go? Doesn't matter, hire the best ones and let them use Python/R/Clojure. HTTP doesn't care.

Re:The End of Microservices by lmm on Thursday July 21, 2016 @12:16PM (#12137824)
> 1. Being able to scale individual, smaller components rather than one giant application

Why does the size of the application matter? Sure it'll take up a little more disk space, maybe even some memory, but probably less than the overhead of splitting into components. Two copies of a monolith wastes less RAM etc. than five components of which you deploy two copies of one.

> 2. Being able to build-and-deploy any one module much faster than one monolithic bundle of local dependencies

Maybe, but first see if you can make build-and-deploy of the whole thing fast. Remember that microservices will slow you down a lot in the case where you do need to spin up multiple components (e.g. every time you spin up a dev instance).

> 3. Universal interface with language-agnostic applications. Do you need to expose big data statistical analytics, but can't find data engineers that are comfortable with Java/Node.js/Go? Doesn't matter, hire the best ones and let them use Python/R/Clojure. HTTP doesn't care.

When you have an actual use case for a HTTP interface then of course you should expose one. But most of the time, YAGNI.

Re:The End of Microservices by krisdol on Thursday July 21, 2016 @04:06PM (#12139638)
I described some of the benefits I am currently experiencing from using microservices where we previously had a monolith.

Spinning up multiple components generally takes a few seconds once the image is built, as it is not much more involved than spinning up a new docker container of an image that is already pulled. Each image might take a couple of minutes to build, but because there are no hard dependencies between images (unlike libraries in a monolith) any amount of them can be building and deploying in parallel.

It doesn't really matter how fast the "whole thing" can be built-and-deployed before, because in a monolith, you need every developer building and deploying their own library versions as well as the monolith. Meaning, not only do your changes to production have to wait in the queue for everyone else's, but you unintentionally pick up work from other folks along the way. That road leads down to the environment you describe, where every developer needs at some point to spin up their own dev instance and live on their own branch just to be able to test in isolation, resulting in an organization that requires merging, building, and deploying several times along the way in different environments before the change finally reaches production.

I also described a perfect use case of an HTTP interface (or RPC, or whatever language agnostic interface you want to use, it doesn't matter to me and rarely matters in the real world). Data science work is often in a different language space than web work. I'm not going to bundle native Python/R/Clojure dependencies with my node.js apps. It's too much work to maintain those bindings between runtime versions and app versions. I'm not going to force Data scientists to use JS because the library ecosystem is targeted toward completely different use cases. With HTTP or RPC or whatever transport, each team can use the best tools for the job.

Re:The End of Microservices by lmm on Friday July 22, 2016 @06:01AM (#12142662)
> I described some of the benefits I am currently experiencing from using microservices where we previously had a monolith.

Sure - I do appreciate it. It's just that my experience in a company that used both was that the microservices weren't worth it - more generally I think a lot of people leap on microservices without thinking about other ways to achieve what they want - so I want to fully work through the options.

> Spinning up multiple components generally takes a few seconds once the image is built, as it is not much more involved than spinning up a new docker container of an image that is already pulled. Each image might take a couple of minutes to build, but because there are no hard dependencies between images (unlike libraries in a monolith) any amount of them can be building and deploying in parallel.

You can do a parallelized build for a monolith too - each component can build in parallel. (Assembling the final image obv. has to be done at the end, but it's a small part of the build time).

> It doesn't really matter how fast the "whole thing" can be built-and-deployed before, because in a monolith, you need every developer building and deploying their own library versions as well as the monolith. Meaning, not only do your changes to production have to wait in the queue for everyone else's, but you unintentionally pick up work from other folks along the way. That road leads down to the environment you describe, where every developer needs at some point to spin up their own dev instance and live on their own branch just to be able to test in isolation, resulting in an organization that requires merging, building, and deploying several times along the way in different environments before the change finally reaches production.

If your team structure is such that you need individually versioned components (which has its pluses and minuses), you can do that while still having a single final deployable.

> I also described a perfect use case of an HTTP interface (or RPC, or whatever language agnostic interface you want to use, it doesn't matter to me and rarely matters in the real world). Data science work is often in a different language space than web work. I'm not going to bundle native Python/R/Clojure dependencies with my node.js apps. It's too much work to maintain those bindings between runtime versions and app versions. I'm not going to force Data scientists to use JS because the library ecosystem is targeted toward completely different use cases. With HTTP or RPC or whatever transport, each team can use the best tools for the job.

I think it's worth mentioning a lot of people jump to HTTP without thinking, when actually something like Thrift is much better suited to an rpc-like use case.

I've actually come to think that the best languages are general-purpose languages and you should just use one language (Scala) for everything. I accept that that's a minority viewpoint though.

Re:The End of Microservices by laingc on Friday July 22, 2016 @10:50AM (#12143838)
> I've actually come to think that the best languages are general-purpose languages and you should just use one language (Scala) for everything.

I disagree very strongly with this. My original background is in scientific programming, which I learned primarily during my PhD. Since then I've been working in, and now leading, teams comprised of both data scientists (principally from a scientific or mathematics background) and data engineers (primarily from a software engineering background). I can tell you from experience that trying to do everything in one language works extremely poorly in practice.

Scala is a great example. People who focus primarily on scaling out relatively simple data processing systems, perhaps with some machine learning thrown in, are big fans of scala. Any scientific programmer that I know (note that machine learning, the most popular kind of scientific programming on HN, is only one very tiny part of the field), including the data scientists in my team, simply cannot do their jobs with scala.

The typical patterns scala encourages are fundamentally unsuited to advanced scientific programming, which is why almost nobody in academic science uses scala [insert obligatory indignation about the wonders of functional programming here]. The number of scientific libraries available for scala is absolutely dwarfed by the C++/Python ecosystem.

Note that I'm not saying that scala is a bad language; I'm saying that every language has advantages and disadvantages for different kinds of work, and different mindsets.

I won't presume to accuse you of this, because I don't know your position, but this kind of viewpoint is typically held by the kind of programmer who dramatically underestimates the complexity of scientific programming.

Re:The End of Microservices by lmm on Friday July 22, 2016 @11:16AM (#12144045)
Shrug. In a previous job I ported scientific code from R to Scala and 99% of the time it was very straightforward. I'm not saying that scientific code is easier than any other code (if anything the opposite is true), I'm saying that the things that make a good language for science are the same things that make a good language for anything else.
Re:The End of Microservices by xorcist on Thursday July 21, 2016 @05:09AM (#12135658)
Because we have to reinvent the message bus every fifth year, so we have to de-invent it in between.
Re:The End of Microservices by bigdrum on Thursday July 21, 2016 @03:43PM (#12139482)
Well, I guess most web app are built by php, Python which do not have a good module isolation / viability enforcement feature, and weak type system. So that's how adding a network layer can prevent people from abusing the interface.
Re:The End of Microservices by pjmlp on Thursday July 21, 2016 @05:18AM (#12135689)
I have been doing it since the early 90's.

It is called unit, module, package, library.

No need to put some network layer, with its own set of problems, between method/function calls.

Re:The End of Microservices by lobster_johnson on Thursday July 21, 2016 @11:43AM (#12137587)
Libraries typically don't have databases or daemons. It's operationally very different.

Can I envision a language-specific framework wherein "microservices" are just plugins that implement interfaces (Java interfaces, for example) for exposing RPC endpoints, which you then "mount" in your framework, allowing developer-enforced separation of concerns, but still allowing a single codebase to share things like config structures, database accessibility, etc.?

Sure. I can't imagine why anyone would want to do it that way, though. For example, you couldn't realistically open-source one of your services, or write it in a different language. Service-specific database stuff would get hairy, quickly. And so on.

Re:The End of Microservices by pjmlp on Thursday July 21, 2016 @01:36PM (#12138536)
Daemons are called threads and coroutines.

As for the rest, that is what a proper design of module interfaces is supposed to be.

Apparently too many people nowadays don't read books about ADTs (Abstract Data Types).

Re:The End of Microservices by carterehsmith on Thursday July 21, 2016 @02:50AM (#12135208)
You are not getting more reusability from a bunch of microservices, compared to one big service, I don't see where you got that?
Re:The End of Microservices by vog on Thursday July 21, 2016 @03:06AM (#12135254)
I also don't see how microservices are more reusable.

However, the replacability is usually much better due to being forced to define sharp boundaries with clear interfaces.

Re:The End of Microservices by pjmlp on Thursday July 21, 2016 @05:21AM (#12135696)
But that is the thing.

It just means that instead of using the language features and creating clean interfaces across modules, they were witting spaghetti code.

With microservices they get to write spaghetti REST calls with the added fun of distributed computing failures.

Re:The End of Microservices by IshKebab on Thursday July 21, 2016 @07:47AM (#12136180)
Normal software libraries also have sharp boundaries with clear interfaces. Why use shitty RPC-over-HTTP? At the very least you can use something sane like Thrift.
Re:The End of Microservices by sanmon3186 on Thursday July 21, 2016 @05:31AM (#12135738)
> the replacability is usually much better due to being forced to define sharp boundaries with clear interfaces

If by "sharp boundaries with clear interfaces", you mean API specification, how is it a microservice thing? I thought the benefits of microservices lie in behind-the-scenes details.

Re:The End of Microservices by _pmf_ on Thursday July 21, 2016 @03:12AM (#12135267)
I think it's the old loose coupling vs. late binding discussion. Some people confuse the former with the latter.

You can very mechanically achieve late binding with microservices, but it takes extra effort to actually achieve loose coupling; and guess what, the effort might or might not be less than doing loose coupling within the components of a monolith.

Re:The End of Microservices by kevinr on Thursday July 21, 2016 @03:37AM (#12135349)
I was just reading the other day this article about the Backend for Frontend pattern (BFF) which suggests the best way to avoid tight coupling is for services you don't want tightly coupled to be owned by different teams, and to allow reasonable duplication of functionality between them. Everybody knows how hard it is to get another team to implement functionality for you.

This is where I got the BFF pattern from:

http://samnewman.io/patterns/architectural/bff/

Re:The End of Microservices by _pmf_ on Thursday July 21, 2016 @05:25AM (#12135714)
I fully agree with this. If a system cannot be extended by some external team using only external extension points, all claims of modularity and architecture are idle talk.

I tend to use MEF (on .NET) and OSGi (on the JVM) not because I actually need extensibility, but because I want to enforce certain architectural constraints.

Re:The End of Microservices by lobster_johnson on Thursday July 21, 2016 @11:37AM (#12137554)
You missed my point. I did not say reusability is the only factor that dictates the use of microservices.

If we wrote everything as one big service, we'd lose the dozen-or-so benefits of microservices.

Hypothetically, if we rewrote what we have today as one big monolith:

* We couldn't selectively open-source parts of it.

* It'd really all have to be a single language, as opposed to the three we use right now.

* ...and if we decided to change the language (like we're in the process of doing with a transition from Ruby to Go + Node.js), we'd have to rewrite all of it.

* Deployment would be potentially more brittle since you're deploying a single codebase. Our apps are designed to gracefully tolerate partial unavailability.

* We'd have to be careful to control individual services' resource footprint. We have some services which are super light and have very few dependencies — they don't carry a monolith on their back.

* We'd have to jam in product-specific stuff for N different products into a single codebase. Some of our microservices aren't reusable; they're completely product-specific. Squishing lots of unrelated concerns into a single codebase is not feasible.

* Developers would be trying to tightly couple services and violate separation of concerns faster than you can spell "technical debt".

...and so forth.

Maybe I didn't articulate it well enough, but my original point was that microservices are great for all sorts of reasons, but also a too-often missed point is the benefits of reusability if you just design thing right.

Put differently, microservices are a lot less powerful if you don't design them for reusability (and, as a prerequisite, multi-tenancy)

Re:The End of Microservices by onion2k on Thursday July 21, 2016 @03:17AM (#12135287)
You are if you care about whether you're deploying things that aren't necessary. With microservices you can take a single specific service that two projects share and reuse it. With a monolith you can't unless you deploy everything else as well. That can easily fail a requirements check (say, hardware requirements are too costly) and force you to redevelop the service for the second project.
Re:The End of Microservices by weego on Thursday July 21, 2016 @03:33AM (#12135339)
I'm not trying to be facetious, but isn't that just called a library?
Re:The End of Microservices by onion2k on Thursday July 21, 2016 @03:57AM (#12135421)
Not as I understand microservices. A library would be something that's compiled or included in to your application code. A microservice is a separate process that the application communicates with over a protocol (eg http).
Re:The End of Microservices by sbov on Thursday July 21, 2016 @04:11AM (#12135466)
I think the point is you can achieve the same result by just using a library.

There are potential benefits and downsides to services over libraries of course, but unless there are specific requirements that make a library unsuitable, all else equal I would rather just use a library.

Re:The End of Microservices by jcrites on Thursday July 21, 2016 @05:11AM (#12135670)
There are a number of downsides of libraries that make services attractive by comparison. Of course, it's not as if one or the other is better in all circumstances.

First, libraries don't encapsulate very well. A storage service hides its representation from users. A storage service can change its implementation at any time without users having to know or care. Perhaps you migrate from Cloud Provider X to Y. A shared storage library, on the other hand, can't just change its implementation on a whim. Libraries vend functionality, and they encapsulate functionality at a coding level, but they don't encapsulate much at a systems level, especially in distributed systems. For example, if this function would talk to a data store like a database or another remote service, then under the service approach, only one application talks to the database, while with the library approach, a ton of applications using the library do -- and now they all need network access to that DB and credentials to talk to it. They care about the details of how to reach it. Every library consumer needs that configuration.

With a service, you can implement security features like input sanitization and access control on the service-side. With a library, you're reliant entirely on trusting its users. (A library can have these functions too, but a malicious user or attacker can bypass them if they compromise the machine it's running on. A service implementation runs in a different security context.)

When a library changes, you need to tackle the problem of distributing the new version to every application that uses it. When a service changes, you just deploy the new version, and all systems using it immediately experience the new version. When a service changes, you can completely coordinate the way in which the new functionality rolls out. You can pass 1% of requests through a new version of the code, if you want. You can pass requests through both versions of the code, and compare one to the other. You can in principle do these things with a library, but few organizations have the ability to roll out updates to all usages of a library nearly as effectively as they can change and redeploy a service. Services allow the service owner to centrally control the behavior of the functionality in all circumstances where it's used.

Libraries don't help you scale different parts of your system differently. For example, let's say that the storage service needs to cache a lot of content for good response times. If that's a library, then all of the applications using it need to have adequate RAM or disk for the cache. With a storage service, that can be hidden behind the service interface, and only the machines running the service need the extra RAM/disk.

Services are portable in a way that libraries are not. A library needs to be implemented in a way that can be consumed within many platforms. For example, it might not be easy to vend the same function for applications on Windows, Ubuntu, MacOS. With a service, I might vend only an interface description, or lightweight clients for the platforms I target.

A service separates the consumption of the functionality entirely from its operation. If there's a defect in the service, like it's returning the wrong result, then that's the service owner's problem to fix and roll out an update. If the library everyone is using in their applications is returning the wrong result, then that's now everyone's problem.

With a service, I can measure anything and everything I might want to know about the behavior of an operation. I can record metrics and log files and anything I want. With a library, there isn't always an easy way to get the information out of applications that use it. Services make applications easier to understand and troubleshoot, because you can reduce the amount of code running on any given machine (VM) to the smallest reasonable amount, compared to applications that embed potentially many libraries. Debugging a library is tricky because you need to debug the application too. I can debug or instrument a service all on its own, without affecting its clients.

The right answer to this question might depend on the scale of the component's usage, the scale of the functionality, and how much you care about these properties, and encapsulation, and coordinated update, etc. Services start to become compelling at a sort of inflection point where you have a lot of usage, enough that updating all applications using a library would be problematic, and you want to decouple things (both components within software and the organizations that develop and run them). I probably have more to say about this, but I'll leave it here. There are plenty of reasons why you'd choose to make something a library, but there are also good reasons why to choose a service.

Re:The End of Microservices by onion2k on Thursday July 21, 2016 @05:11AM (#12135669)
Microservices also enable you to scale individual parts of your application. If you need better performance for, say, image compression then it's much easier to add resources to a service that lives in its own process space (or its own server, or rack of servers, or data centre..) than it is to improve the performance of a specific library in a larger application.
Re:The End of Microservices by zby on Thursday July 21, 2016 @04:37AM (#12135553)
With some work you can have the some behaviour - but the microservice is also about the data (like user ids and passwords for a login microservice).
Re:The End of Microservices by jbverschoor on Thursday July 21, 2016 @04:34AM (#12135547)
So you deploy your easy to manage monolith, and expose your library through an rpc service. rest, thrift or whatever is hip these days.
Re:The End of Microservices by rodgerd on Thursday July 21, 2016 @03:20AM (#12135298)
From experience at the classic ball o' mud web servicey end of the spectrum, because it gets to hard to manage and deploy and test services that you end up standing up new services to do "the same thing only slightly different" because reusing existing services is too hard.
Re:The End of Microservices by fleitz on Thursday July 21, 2016 @03:05AM (#12135243)
It's especially fun when you get to write the monolith 3 times over for web, ios and android.
Re:The End of Microservices by carterehsmith on Thursday July 21, 2016 @06:58PM (#12140636)
Why would you write it three times?

You write it once, have it expose an API. Have your Web, IOS and Adroid client use the said API. Easy pease. Optional: allow your customers to use the API, too.

Re:The End of Microservices by fleitz on Saturday July 23, 2016 @02:38AM (#12148613)
That's not 'microservices'
Re:The End of Microservices by collyw on Thursday July 21, 2016 @03:35AM (#12135344)
Sounds kind of like what I would do, except I would use a database table / controller for each of the things you consider a microservice.