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

REST API vs gRPC, which one should you use in b...

REST API vs gRPC, which one should you use in breaking a monolith [Voxxed Days Microservices 2018]]

You heard of "new thing" called gRPC and promises that it will solve all issues for you, so now you are not sure if you should use it for breaking up your monolith to Microservices. If it is good for Google it should be good for you also right?

On the other hand, you have been using REST API's for some time now, at least as a consumer, so maybe this would be better approach in Microservices waters, or would it?

Which one to chose and which one will fit your use case better?

Join me in this talk were I will try to explain both approaches, good and bad. I will give some points and tips, which will help you in understanding better which one will be better for you. By doing this I will also share some best practices for both approaches

Code: https://github.com/vladimir-dejanovic/grpc-bank-example

Vladimir Dejanovic

October 30, 2018
Tweet

More Decks by Vladimir Dejanovic

Other Decks in Programming

Transcript

  1. @devconfpl @VladimirD_42 REST API vs gRPC Which One Should You

    Use in Breaking a Monolith Vladimir Dejanović @VladimirD_42 30th October 2018
  2. @VladimirD_42 #VoxxedMicroservices REST in Real Life import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.repository.query.Param;

    import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends MongoRepository<Person, String> { List<Person> findByLastName(@Param("name") String name); }
  3. @VladimirD_42 #VoxxedMicroservices REST in Real Life import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.repository.query.Param;

    import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends MongoRepository<Person, String> { List<Person> findByLastName(@Param("name") String name); }
  4. @VladimirD_42 #VoxxedMicroservices REST in Real Life import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.repository.query.Param;

    import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends MongoRepository<Person, String> { List<Person> findByLastName(@Param("name") String name); }
  5. @VladimirD_42 #VoxxedMicroservices REST in Real Life import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.repository.query.Param;

    import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends MongoRepository<Person, String> { List<Person> findByLastName(@Param("name") String name); }
  6. @VladimirD_42 #VoxxedMicroservices REST in Real Life import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.repository.query.Param;

    import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends MongoRepository<Person, String> { List<Person> findByLastName(@Param("name") String name); }
  7. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  8. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  9. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  10. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  11. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  12. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  13. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  14. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  15. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  16. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...
  17. @VladimirD_42 #VoxxedMicroservices ... message TransferMoney { int32 trans_id = 1;

    int32 from_account_number = 2; int32 to_account_number = 3; double amount = 4; string message = 5; } service Bank { rpc Transfer(TransferMoney) returns (TransferConfirmation); rpc ListenToNotifications(Account) returns (stream AccountNotification); rpc RequestTransfer(stream RequestMoney) returns (stream RequestStatus); } ...