Live data from Hacker News

MicroservicePremium

martinfowler.com

11–20 of 27 posts

Re: MicroservicePremium

#11
post #8

What is a monolith? Intentionally tightly coupled code that you feel is going to be manageable in the future? I think the biggest anti-pattern is "DRY". This turns a simple rails view into a monstrosity that is used to render every page of a site, or a class into a self-referencing recursing mind-puzzle. When a codebase starts down the monolithic path, developers will often use the DRY anti-pattern to "shrink" what i…

There are two ways to think about microservices. Development (which your comment focuses on) and deployment. The pure/idealized microservice is isolated from the rest of your environment/codebase on both of those axes. In practice, there will be some coupling on both, and perhaps one of those isn't isolated at all. The monolith is simply the opposite of the microservice ideal, it is heavily coupled in both developmen…

Makes sense. I typically try to design things so that they are initially joined (for convenience) but can easily be split off -- such as a simple router between micro-apps which can be replaced by haproxy (or similar) later.

Re: MicroservicePremium

#12
Yao Yu made some observations in her (excellent) talk about caching at Twitter over the years (https://youtu.be/rP9EKvWt0zo) that stuck with me: having a bunch of services doesn't itself isolate problems within one service. Twitter's cache service had to deal with clients rampaging to all load the same key zillions of times, for example.

The impression that gives me is that some of the gain from microservices might be from doing all of the things we're used to doing at service boundaries: documenting APIs, sanity-checking requests, logging, monitoring availability/resource usage/other metrics, etc.--the same sort of things any public Web service does knowing it's going to have to deal with funny clients, rising and falling load, and so on.

If all of the stuff it would take to properly maintain another usable customer-facing service sounds too expensive, that may be a sign that this isn't the place to split off a service. But if you find yourself wishing for separate monitoring, a cleaner API, etc. around some part of your system, it becomes more interesting to separate.

(I can also buy that some folks can see organizational benefits, or benefits from isolating hardware or making operations async, but separate ideas.)

Re: MicroservicePremium

#13
I have some experience designing and working on this style of architecture in a non-enterprise non-bigco environment. Some things I learned over the years:

1) If the system is young and the team is small, consider imposing constraints onto the system that remove certain classes of problems entirely. You can later lift these constraints as the team grows. [1]

2) Your ops environment must be capable of multiplexing multiple services onto the same virtual machine. The way you provision and classify machines is affected by this. Services, by their nature, are small and are likely going to be I/O bound. Deploying multiple services onto a single machine is very cost effective.

3) If you're starting with a monolith, the best early candidates to break off are things like search, graph stuff (eg: Neo4j), recommendations, activity feeds, image processing, and other important but non-critical things. It's a great way to drum up support for this architectural style and/or test how useful it will really be.

4) Unless your engineering team has a polyglot culture (good for you!), be careful about introducing your favorite language when building a new service. Alienating services is a great way for them to rot.

5) I've been asked how to define a service. Should X be one service? Should X be split into two services? A good way to start is to think about data locality. When a "user" is fetched are "friends" almost always queried too? If so, keep them together. The next thing to look at are traffic patterns. Another thought exercise is to ask, "if our startup makes a hard pivot tomorrow, what are we likely going to keep? Users?".

6) Do what makes sense. A small startup with a 5 person team doesn't need 20 "microservices" to maintain. It's an operational burden. Break things away in stages on an as needed basis. I've actually found that keeping around the monolith is a great outlet for rapidly prototyping. Give the monolith a beefy database and an in-memory datastore. When you need to prototype a feature for a week, feed it to the monolith. When it's ready for production, break it off if it makes sense.

7) If your ops environment is underdeveloped, it'll hurt bad. The value of a good ops person cannot be overstated (esp. if you're dealing with rapid growth). They're wizards. Learn everything you can from them.

[1]: I like to impose a constraint that no service is allowed to talk to any other service unless it is: a) customer facing (eg: the website or the mobile api), or b) non-critical and low volume. At first, your services will act as self contained front ends to their databases. Your customer facing applications will stitch together responses from these services (hopefully in parallel). You'll have a clear understanding of how data flows in your system.

Re: MicroservicePremium

#14
post #8

What is a monolith? Intentionally tightly coupled code that you feel is going to be manageable in the future? I think the biggest anti-pattern is "DRY". This turns a simple rails view into a monstrosity that is used to render every page of a site, or a class into a self-referencing recursing mind-puzzle. When a codebase starts down the monolithic path, developers will often use the DRY anti-pattern to "shrink" what i…

There are two ways to think about microservices. Development (which your comment focuses on) and deployment. The pure/idealized microservice is isolated from the rest of your environment/codebase on both of those axes. In practice, there will be some coupling on both, and perhaps one of those isn't isolated at all. The monolith is simply the opposite of the microservice ideal, it is heavily coupled in both developmen…

There's an additional aspect... Types of load (compute vs i/o)... I'm currently building a system where node/iojs is the primary application runtime. In this case, separating those portions of the application that are compute heavy (resizing images, recalculating values, etc) are offloaded, beyond that I have separated the backend data into discrete containers based on collections of data/types... that which is related to an account, vs that which is related to a user/profile (and authentication)... which makes a bit more sense. I also separate the authorization as a service layer above backing logic.

UI (shared client/server codebase), WebAPI (ui access, auth filtering), DataAPI (used from WebAPI), Profile Service (users/auth), Account Service (core data), Image Service (backs upload/resize) and various backing pieces... for me I didn't break things up into too fine grained pieces, but wanted breaks based on type of work and/or data.

It really just depends on your workload.

Re: MicroservicePremium

#15

Yao Yu made some observations in her (excellent) talk about caching at Twitter over the years ( https://youtu.be/rP9EKvWt0zo ) that stuck with me: having a bunch of services doesn't itself isolate problems within one service. Twitter's cache service had to deal with clients rampaging to all load the same key zillions of times, for example. The impression that gives me is that some of the gain from microservices might…

There's also load... If you have a specific service that needs more resources, you can allocate more instances of that service on more machines.

Re: MicroservicePremium

#16

Does this feel like backtracking to anyone else? Compare to Fowler's previous discussions [1]. Maybe it's just hard to write about a new, interesting thing without most people getting the impression you think it's the way (especially developers, who seem eager to declare any new tool the One True Way® and everything else 'legacy'). [1] http://martinfowler.com/articles/microservices.html#AreMicro...

No? > So we write this with cautious optimism. So far, we've seen enough about the microservice style to feel that it can be a worthwhile road to tread. We can't say for sure where we'll end up, but one of the challenges of software development is that you can only make decisions based on the imperfect information that you currently have to hand

Integrating lots of points is a pain in the ass. Integrating a new service was a 13 in a sprint. Adding a field to an existing service is 3. Often the aggregation gets pushed into the front end layer as well so the customer workflows get mixed with the service logic. Which is not pretty.

Re: MicroservicePremium

#17
post #2

my question is, what happen is eventually some tools can be useful for overcoming the complexity introduced by microservices (e.g. CoreOS, docker, kubernetes, Netflix OS technology, etc), what could be the argument for not using them instead big monoliths?

Well, for example kubernetes/coreos create their own complexities, of which docker is only part (you can even roll your own, but this takes time/effort), that doesn't even handle CI/CD parts, or manual intervention steps. There's operations overhead for these solutions.

If you are a mid/large sized organization it becomes easier to take different approaches... if your single ops guy on a 5-man dev+ops team is overwelmed, and your other main ops person is tied up with coding/architecture then even flushing out such a system is difficult. We're using wildcard DNS to make routing from nginx more straight forward, and deploying each service to 3 dokku-alt servers... which is easier than some of the dynamic provisioning and other pieces behind say coreos/kubernetes.

For that matter, we're keeping our semi-microservices in check, only having a few of them for user-accessed data, and a handful of others for handling work queues.

Re: MicroservicePremium

#18

Yao Yu made some observations in her (excellent) talk about caching at Twitter over the years ( https://youtu.be/rP9EKvWt0zo ) that stuck with me: having a bunch of services doesn't itself isolate problems within one service. Twitter's cache service had to deal with clients rampaging to all load the same key zillions of times, for example. The impression that gives me is that some of the gain from microservices might…

There's also load... If you have a specific service that needs more resources, you can allocate more instances of that service on more machines.

(Yep, totally agree--was trying to get at how there could be other benefits in the last parenthetical comment. The extra process we do at service boundaries just stood out at me from the caching talk.)

Re: MicroservicePremium

#19

I have some experience designing and working on this style of architecture in a non-enterprise non-bigco environment. Some things I learned over the years: 1) If the system is young and the team is small, consider imposing constraints onto the system that remove certain classes of problems entirely. You can later lift these constraints as the team grows. [1] 2) Your ops environment must be capable of multiplexing mul…

[deleted]

Re: MicroservicePremium

#20
post #19

I have some experience designing and working on this style of architecture in a non-enterprise non-bigco environment. Some things I learned over the years: 1) If the system is young and the team is small, consider imposing constraints onto the system that remove certain classes of problems entirely. You can later lift these constraints as the team grows. [1] 2) Your ops environment must be capable of multiplexing mul…

[deleted]

(edit: The above commenter deleted their post as I wrote my reply. They made the point that the traditional architecture of offloading email and image processing is suitable for background queues/workers and don't necessarily need to be services. This is very true; my reply points out when you might actually want to do it.)

They don't have to be, but they can be.

For image processing, you might to process (and cache) images on the fly. This is very, very useful for companies that manage a lot user uploaded media. Processing images in the background forces you to decide ahead of time what dimensions, formats, filtering, etc you want. Adding another image variant means running a backfill on all existing images. There are a few open source libraries that exist (I contributed to https://github.com/oysterbooks/halfshell, but there are others) and SASS solutions (https://www.imgix.com/).

For sending emails, I've built an API that does more than simply route emails to a 3rd party. The marketing team was given a simple interface to edit transactional email templates, A/B test them, track engagement, manage unsubscribe lists, and embed dynamic content. This service also sent SMS and push notifications.

It really depends.

Post reply on HN