WHAT'S NEW?
Loading...

Building microservices in .Net - Ian Cooper's conference

Who?

What microservices are?

Microservices is a software architecture design pattern in which complex applications are composed of small, individually deployables, independent processes communicating with each other using language-agnostic APIs. These services are small, highly decoupled and focus on doing a small task.


Services

Components

Are:
  • Object (OOP)
  • Well defined interface
  • Server
  • Language transparency
  • Platform transparency
  • Discoverable


Properties:
  • Decoupling
  • Decomposition: (aka factoring) breaking a complex problem or a system into parts that are easier to conceive, understand or maintain.
  • Testable: there are some encapsulation in them you need to validate.
  • High cohesion: because data and methods that operate on that date are collocated we are highly cohesive



Remote Procedure Call (RPC): call of methods. Examples: COM, DCOM, CORBA, JAVA RMI, .NET Remoting… (SOAP is a type of RPC)

Messaging: some components use messaging to provide support for sending asynchronous messages between components usually server MOM (Microsoft operations manager)

Disadvantages: The fallacies of distributed computing. The principle of transparency there should be awareness that a call is in process of out access fails of the fallacies of distributed computing. RPC will fail.

SOA


Service provider

  • Autonomous: a service is maintained, developed, deployed and versioned independently of all other services
  • Explicit boundaries: service has explicit boundary, well defined interface, and accessing the service is only through that boundary, a service own its data and does not use shared database integration, the data is hidden behind the boundary
  • Share schema and contract, not type:  avoid platform coupling. No object broker is required as lifetime management is not the province 
  • Compatibility is based on policy: compatibility of a port is advertised by identifying the protocols it supports.
  • Distributable: a service can be located anywhere on the network, local or remote as long as the network supports the required protocl

Properties:

  • Decoupling
  • Decomposition
  • Testable
  • High cohesion

Timeout pattern

Always timeout your calls depending on your measures of time of your different process.

Retry pattern

Always retry at least one more time, sometimes you will face problems because of network issue or a kind of latency so no worries to retry again a call.

The circuit breaker pattern

The general idea within this pattern is basically wrap a protected funciton call in a circuit breaker object, which monitors for failures. Once the failures reach a certain threshold, the circuit breaker trips, and all futher calls to the circuit breaker return with an error, without the protected call being made at all, Usually you'll also want some kind of monitor alert if the circuit breaker trips.

Atom feed

Choosing Atom (xml messaging format) over Json will provide you more consistency in your messages but maybe it could incur less performance.
In XML, you can add a child element or an attribute to anything you want. XML namespaces can be used to prevent clashes. Software that encounters these extended attributes and elemnts doesn't break; it can simply igonre them.
In JSON however, extensions is not so easy. How do I extend a given JSON object with new data? I can add a new property (assuming it doesn't clash with a current or future one), but extending a given property is harder. If JSON property value is a number, how do I add more information?



Operating Microservices

Tooling: how do I deploy my services
Configuration: How to I configure my services
Discovery: How do I find what services are out there
Routing: How do I route requests between services
Observability: How do I monitor the health of my services
Datastores: SQL, NoSQL, etc.
Operational: Hosting, Orchestration
Development: languages, platforms, containers

Tutorial

Example application developed by Ian Cooper to manage operation within a commercial store where you can add, edit and remove products / orders and this app is using RabbitMQ as messaging system.

In the following link you can see a tutorial in C# for micro services provided by Ian Cooper:
https://github.com/iancooper/Microservices-Tutorial

Known uses

Most large scale web sites including Netflix, Amazon and eBay have evolved from a monolithic architecture to a microservices architecture.

Netflix, which is a very popular video streaming service that’s responsible for up to 30% of Internet traffic, has a large scale, service-oriented architecture. They handle over a billion calls per day to their video streaming API from over 800 different kinds of devices. Each API call fans out to an average of six calls to backend services.

Amazon.com originally had a two-tier architecture. In order to scale they migrated to a service-oriented architecture consisting of hundreds of backend services. Several applications call these services including the applications that implement the Amazon.com website and the web service API. The Amazon.com website application calls 100-150 services to get the data that used to build a web page.

The auction site ebay.com also evolved from a monolithic architecture to a service-oriented architecture. The application tier consists of multiple independent applications. Each application implements the business logic for a specific function area such as buying or selling. Each application uses X-axis splits and some applications such as search use Z-axis splits. Ebay.com also applies a combination of X-, Y- and Z-style scaling to the database tier.

References

http://es.slideshare.net/adriancockcroft/microservices-the-good-bad-and-the-ugly
http://microservices.io/patterns/microservices.html
https://github.com/iancooper/Microservices-Tutorial
https://en.wikipedia.org/wiki/Atom_(standard)
http://martinfowler.com/bliki/CircuitBreaker.html
http://metajack.im/2010/02/01/json-versus-xml-not-as-simple-as-you-think/

0 comments:

Post a Comment