The word service means two things

Free preview 3 min to read

This application contains 54 files ending in _service.rb. It needs no service mesh, and understanding why those two facts sit together is most of what this course is for.

Two different things with one name

A service object is a Ruby class with a call method. Auth::AuthenticateUserService, Enrollment::StartCourseService and Partners::FetchSiteIconService are invoked as method calls, in the same process, on the same stack.

A service in the distributed-systems sense is a separate process, usually on a separate machine, reached over a network.

A service mesh connects the second kind. It has nothing to offer the first, because the first has no network between its parts.

What the network adds

A method call either returns or raises. Those are the only two outcomes, and both are immediate.

A network call has a third outcome: no answer. The request may have arrived and been processed, arrived and not been processed, or never arrived, and the caller can't tell these apart.

flowchart TB
  M["a method call"] --> R1["returns"]
  M --> R2["raises"]
  N["a network call"] --> R3["returns"]
  N --> R4["raises"]
  N --> R5["no answer at all"]
  R5 --> U["did it run? the caller cannot know"]

Everything a mesh does exists because of that third outcome. A network also adds latency, serialization, authentication between parts that used to trust each other, and the problem of finding the other side at all.

The five concerns

Distributed services need answers to the same five questions, and a mesh is one place to put them.

Discovery: where is the other service right now?

Security: is this caller who it claims to be, and is the traffic encrypted?

Reliability: retries, timeouts, and knowing when to stop trying.

Traffic control: canaries, mirroring, splitting by version.

Observability: which call in the chain was slow, and which one failed?

This application answers all five, and every answer is "not applicable, there's one process". That's the design working, not a gap.

Key takeaways

  • This application has 54 service objects and needs no mesh, and both facts follow from the same design.
  • A service object is a method call, and a service in the distributed sense is a process across a network.
  • A method call returns or raises, and a network call can also not answer at all.
  • Everything a mesh does traces back to that third outcome.
  • The five concerns are discovery, security, reliability, traffic control and observability.
Lesson 1 of 7 · free

Keep going with lesson 2

The sidecar you already run

The sidecar proxy handles the network beside each service, and Thruster in front of Puma is a small example.

A free account also gives you the quizzes, your progress and notes, and the discussion.

Type to start searching...