Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modern ways to allow function calls across the network

Think of this as a survey of modern system design paradigms:

Let's say I've written a program to return the sum of 2 given numbers. Let's call it the Amazing Adder.My goal is to make this Amazing Adder available for others to use. As of 2018, what are the mainstream and modern ways to deliver this Amazing Adder as a publicly available service to the world? I'm more interested in the backend architecture, rather than user interface. Based on my knowledge of systems design,I can think of:

1) Making this a REST service, but does this use case fit nicely into a REST paradigm? How would I call my endpoint? What actions (update, delete, etc) do I need to support, if all I'm doing is adding to numbers without state information?

2) Making this normal JSON RPC over http. So users send in a http POST request to http://www.theAmazingAdder.com/add, with the payload being {'number1':2,"number2":3}, and my service would return {'sum': 3}

3) Making this a binary RPC format via Profobuf or Thrift. Is that overkill? What would be the 'code definition' that both client and server must have?

4) Traditional Python pickling or java serialization/rmi via network ? Is that even appropriate?

Any other popular modern paradigms I have missed ?

like image 298
user1008636 Avatar asked Aug 15 '18 14:08

user1008636


1 Answers

Today (in 2018) the "mainstream" and "modern" way of doing something like this is to use either grpc or have a rest service speced with OpenApi

Which approach to use depends on the context a lot

Why did I pick these 2 approaches? They allow you to define a protocol, an interface for your "Amazing Adder" and then implement it in whatever language you want (provided there's a lib for grpc), at the same time allowing you to auto-generate client libraries in multiple languages based on your proto file.

In grpc, you would define .proto file with your functions and generate client libraries to share with consumers of your service.

like image 175
Alex Kurkin Avatar answered Sep 23 '22 06:09

Alex Kurkin