Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Forget About HTTP - DevSum

Forget About HTTP - DevSum

Irina Scurtu

May 29, 2020
Tweet

More Decks by Irina Scurtu

Other Decks in Technology

Transcript

  1. Irina Scurtu ▪ Romania Based ▪ Software Architect @Endava ▪

    Organizer of DotNetIasi user group ▪ I teach .NET ▪ https://irina.codes @irina_scurtu
  2. Agenda ▪ Monoliths& Microservices ▪ HTTP calls – sync &

    async ▪ RPC ▪ Messaging ▪ Queues ▪ Message Brokers ▪ Actor Model
  3. MONOLITH ▪ Self-contained ▪ Single codebase ▪ Single deploy unit

    ▪ Easy life for developers ▪ Dependencies are in your code ▪ Single technology stack
  4. MONOLITH ▪ All or nothing deploys ▪ Downtimes ▪ Long

    build times ▪ ~ 0 continuous delivery ▪ Hard to test
  5. MICROSERVICE ▪ it’s that thing that is not a monolith

    ▪ With it’s own database ▪ Easy to deploy ▪ Standalone ▪ Easy to maintain Is it?
  6. “It’s perfectly fine to use sync HTTP Calls” ▪ Timeouts

    ▪ Availability ▪ Reliability ▪ Retries? ▪ Code Coupling?
  7. “It’s perfectly fine to use async HTTP Calls” ▪You’ll have

    exactly the same issues as with sync calls ▪Distribute load?! ▪You can serve more request ▪You can serve the requests faster
  8. HTTP General Notes ▪ Sync by nature ▪ Make a

    TCP connection for each request ▪ No retry out of the box ▪ No delivery guarantees ▪ Location transparency ▪ Good for public facing APIs ▪ Familiar ▪ Easy to debug
  9. gRPC ▪ No-code references ▪ Contract based ▪ Uses HTTP/2

    => faster ▪ Efficient ProtoBuf serialization => smaller payload ▪ Available in many languages ▪ Code generation
  10. syntax = "proto3"; option csharp_namespace = "MyFirstGrpc"; package Fibonacci; //

    The service definition. service Fibo { rpc ComputeFibonacci(RequestedNumber) returns (FibonacciResult){} } //the request message format message RequestedNumber { int32 number = 1; } //the response message format message FibonacciResult { int32 result = 1; }
  11. syntax = "proto3"; option csharp_namespace = "MyFirstGrpc"; package Fibonacci; //

    The service definition. service Fibo { rpc ComputeFibonacci(RequestedNumber) returns (FibonacciResult){} } //the request message format message RequestedNumber { int32 number = 1; } //the response message format message FibonacciResult { int32 result = 1; }
  12. syntax = "proto3"; option csharp_namespace = "MyFirstGrpc"; package Fibonacci; //

    The service definition. service Fibo { rpc ComputeFibonacci(RequestedNumber) returns (FibonacciResult){} } //the request message format message RequestedNumber { int32 number = 1; } //the response message format message FibonacciResult { int32 result = 1; }
  13. syntax = "proto3"; option csharp_namespace = "MyFirstGrpc"; package Fibonacci; //

    The service definition. service Fibo { rpc ComputeFibonacci(RequestedNumber) returns (FibonacciResult){} } //the request message format message RequestedNumber { int32 number = 1; } //the response message format message FibonacciResult { int32 result = 1; }
  14. syntax = "proto3"; option csharp_namespace = "MyFirstGrpc"; package Fibonacci; //

    The service definition. service Fibo { rpc ComputeFibonacci(RequestedNumber) returns (FibonacciResult){} } //the request message format message RequestedNumber { int32 number = 1; } //the response message format message FibonacciResult { int32 result = 1; }
  15. syntax = "proto3"; option csharp_namespace = "MyFirstGrpc"; package Fibonacci; //

    The service definition. service Fibo { rpc ComputeFibonacci(RequestedNumber) returns (FibonacciResult){} } //the request message format message RequestedNumber { int32 number = 1; } //the response message format message FibonacciResult { int32 result = 1; }
  16. RPC ▪ A kind of API call ▪Done through a

    message broker ▪ Ties systems together but preserves their encapsulations ▪Makes an external system look ‘local’ ▪No direct code dependencies
  17. Gain vs Loss ▪You don’t lose the requests ▪You can

    add more handler instances ▪You can ‘apparently’ spread the load ▪You can process more requests ▪ Need to match the request to the response ▪ Is still sync
  18. Messaging ▪Gives you loosely coupled integration ▪Doesn’t require both systems

    to be up ▪Messages ca be transformed in transit - Enrichers ▪Messaging systems trade consistency for availability ▪You don’t lose messages -> increases reliability
  19. Gains • Is a reaction to the problems of distributed

    systems • Process more requests • Process request faster • Don’t lose requests ▪ You move the potential issues to another subsystem (DB in our case) ▪ Eventual consistency remains a problem Loss
  20. Solutions to eventual problems ▪ Connection is scarce ▪ Batch

    process the message ▪ Use a semaphore to process them in batches
  21. Agility ▪Faster development ▪No integration process ▪You depend only on

    a response ▪Teams have ownership and full understanding of the codebase ▪You can switch technologies if needed
  22. Actor model ▪Born from Reactive Programming ▪Actors are processes that

    encapsulate behavior ▪Actors are more than message consumers ▪Can delegate and create new actors ▪Can supervise children ▪At most once delivery
  23. Message Brokers ▪One process sends a message to a named

    queue/topic ▪One or many consumers ▪Handles connections and disconnections ▪Dead-letter queue concept ▪Message Guarantees ( 3 types) ▪Different Protocols
  24. AMQP General Notes ▪ Async by nature ▪ Guaranteed message

    delivery ▪ No DNS resolve ▪ Programmatic routing ▪ Retries out-of-the box ▪ Ack, Nack out of the box