HACKER Q&A
📣 taw1516

Best way to open up an internal API between your two servers


We are a small startup of 5 people. Between people coming in and out and poor technical decisions, we ended up with two backend: one in Ruby and one in Go. Both are serving public data via a federated GraphQL API. Most of business domain logics are encapsulated in one server. But we have some shared logic that needs to be implemented in both. Instead of duplicating logic, I want to write these shared 'services' in the new backend (Go) and expose an internal API for Ruby to consume. What's the low lift way for a startup to implement something like this? Is it just a simple REST API consumed via JSON with an API key in the header?


  👤 austin-cheney Accepted Answer ✓
If you need to perform real time messaging between two servers use either RPC or WebSockets. These are bidirectional messaging in binary without a round trip or large plain text header. What the data is, where it comes from, or how its generated is completely irrelevant to the transmission.

I have a Node.js app written specifically for this scenario. You can try my app to see if it solves for your use case. It is designed right now to support file system streaming, text messaging, status messaging, and so forth. It can be supported to messaging anything you need. Remote instruction execution will require more effort for security reasons.

https://github.com/prettydiff/share-file-systems