77 points · by interpol_p · 2y ago · 138 comments
Maybe call it "removes as much friction as possible compared to local functions" but please don't call it "feels [exactly] like local functions". It's simply impossible and pretending so will just cause trouble.
Over the course of my short 20-year career, I've encountered far too many applications that accumulated terrible performance or reliability problems that were directly attributable to their authors feeling a bit too comfortable about getting chatty with the slow, unreliable remote procedure calls.
By contrast, the most successful microservices shop I ever worked at was very conscientious about doing nothing to hide the messiness of RPC. (Ease the implementation, yes, but not hide the messiness.) And that seemed to foster a culture of being much more thoughtful about interaction patterns and data flows and how they might contribute to or detract from the overall performance and stability of the system.
However, I've found the abstraction to be useful when someone _has_ already made the decision to refactor their service out to be a separate service.
Sure, `sprintf` will run synchronously and finish in known time, but `read` may as well end up waiting for seconds for an HDD to spin up, or for a mounted NFS filesystem to respond. `read` is not any different from an RPC call. And, in fact, `read` can fail in just the same ways as an RPC call can. So can `write`, which is why `sync` exists.
Software ignoring these potential issues, and pretending they don't exist, is the source of many unnecessary software hangs and crashes, such as Windows Explorer crashing if your SMB share responds too slowly or Linux being unable to unmount an NFS share if the connection breaks badly.
The solution IMO is that we should finally stop hiding asynchronicity behind synchronous facades. If coroutines, promises, async programming, etc are first-class features, it becomes much easier to cleanly model these potential errors and in turn handle them correctly.
And once you have that, an rpc call
async fn rpcMakePurchase(user: &User, order: &Order) -> Result<Purchase>
does feel just like a local function async fn read(path: impl AsRef<Path>) -> Result<Vec<u8>>There is still a small difference though: when I execute a write and sync, then I'm pretty sure it either succeeded or didn't. I'm not sure if there is any way for the disk to say "don't know" which the OS will then pass to my program. Even if, I guess such a case is so rare that it is probably excluded in any error-model. Like cosmic rays. And I can always retry, since it's very very unlikely that there is a connection issue only between my program and the disk but not between other programs and that disk - since they run on the same machine.
Over a network things are different, because the connection might be gone for a long time and know I'm not aware of the state and I can't check it. I can also not tell if the connection might come back, the machine I was talking to might have burned down. If I, myself, burn down, then I don't need to worry anyways.
That's the difference. This is specific for write/sync though - as you explained it, just because things are running on the same machine does not mean things are necessarily more reliable than a "remote" call.
When modeling rpc calls as async calls returning a result, you can be just as sure that it has completed (or failed) as with a local call.
And considering write can use an underlying mounted network share, a spun-down HDD, or a thumb drive on a failing USB port, the same failure modes exist in either case.
In either case you're just submitting commands to another device's queue (and waiting for a result) over a hot-pluggable connection.
http://armstrongonsoftware.blogspot.com/2008/05/road-we-didn...
Bye, Joe.
We didn't know we were going to be posted on HN, and we're still iterating on copy that "lands". I don't think we've found the words yet.
I agree with the premise that RPC has markedly different characteristics. The actual implementation [1] makes it clear that you're connecting through a client interface.
Thanks for the feedback on calling it "removes as much friction as possible compared to local functions". I think we'll trend this way.
[1] https://docs.differential.dev/getting-started/quick-start/#3...
Nonetheless, what you built sounds quite interesting: can you say anything more about the language, tech stack, etc…?
The result was good but I still don't like transparent rpc (on large dev teams anyway).
In particular, if the "network" is something local to one machine, pcie or some cross-chip fabric thing, where the failure modes of the "network" are the box falls over, then RPC works as one might hope. You don't have to mangle functions to take account of extra network errors because there are none.
The specific use case I'm interested in is heterogenous compute on shared memory machines. Code running on a GPU can call `int rc = fprintf(stderr, "oh dear");` and have no idea whether that runs code on a CPU or not. Code running on a CPU can call some linear algebra function and either run it locally or on a GPU, unobservable to the caller.
That is a good trick. It does make for an interesting debugging experience where you lose track of where code is executing.
----
There's a less esoteric application in the area of the OP for pure functions where you don't need the result immediately. That goes something like:
1. Call the function and get back a promise or similar. All runs locally, no failures
2. Something in the background maybe does the work for you
3. Ask for the result. If it's not available yet, do the work locally
That has the same zero failure modes property because it'll ultimately run all the work locally if the network offloading never works out. It only really makes sense if the functions can be called multiple times (e.g. locally and remote at the same time) without doing harm, i.e. pure functions. It costs latency and gains throughput. For some batch computation work that is great.
So you'd probably need the "not available, but already 'stolen' case". For example, the current machine could look for work to steal itself. But this probably will increase latency a lot, so it would only make sense if the batches are huge.
The problem with the "already scheduled" pattern is when the machine holding the task falls over.
Not a good choice for bank transactions. A good option for something like a distributed build farm - it doesn't matter hugely if you compile some piece of program repeatedly, but it matters a lot if you send the only copy of some source to a machine that immediately goes offline.
Mainly bringing it up as a case in which RPC works beautifully - remote machine failures can be completely hidden by a willingness to do the work locally instead.
But exactly once processing is viable.
With Differential, the implementation does allow for idempotency in cases where you need exactly-once processing. And it does handle the "not available, but already 'stolen' case".
Disclaimer: I'm an author.
Fair enough. Maybe we shouldn't call it remote procedure calls then, because it's not remote anymore. The word remote exists to make the distinction compared to local. If there is no distinction in a given context, there is no need to use that word from the beginning.
There is another big restriction. The sender and receiver have to be in the same process. Else it's possible that the receiver does not exist and there is no way to start the receiver back up.
I generally agree with the fact pretending it's like a local function will cause trouble down the track. After all, you're introducing a number of extra failure modes.
The client library however does give some protections to the developer through the type system - although it's not perfect.
Hence the wording "feel like". It's not actually local function calls. But it abstracts away a lot of the complexity.
"If it's predicted to be transient, Differential will retry the operation on a healthy worker before the client even notices." [https://docs.differential.dev/advanced/predictive-retries/]
I… er… wat? Does that mean this behavior is nondeterministic, driven by what some extra component cooks¹ up on a per-call basis?
…
Doing this without developer input is such a horribly bad idea, and then debug it when something (not even in the RPC layer) goes wrong?
[Edit:] "You can turn this feature on for your cluster using the Console. It's off by default." – a breath of relief.
--
¹ I really had to resist the temptation to say "hallucinates" there.
So, the implementation _is_ deterministic per observed error, that is because it caches the previously cooked up result of "is this retryable or not" and apply it to next observed error without trying to process it for each function call.
Whether it does correctly infer retry-ability - well, that's another question.
It's an opt-in feature, and it's not default-on. So, it does do this _with_ developer input. If you prefer to not use this abstraction and have total control over error handling, you definitely can do that. (And it's the default)
If I reduce the tradeoffs here, it's between: 1. Explicitly handling all your errors for complete control of retry-ability. 2. Using predictive retries when you want some "good enough" error handling.
I agree that we can't really be 100% "correct" in determining whether something is retryable. But I think it's a bounded enough problem for a language processor (ala LLM) that can yield good enough results for vast majority of the use cases.
Here's a test case that asserts this behaviour (without any caching): https://github.com/differentialhq/differential/blob/236ffc53...
So in a way, it is bounded enough to yield this result deterministically in our test suite. But I agree there's a non-zero chance it fails, although we haven't observed it yet after thousands of test runs.
The documentation sounds like it's a global switch though? This is really a per-function property…
> But I think it's a bounded enough problem for a language processor (ala LLM) that can yield good enough results for vast majority of the use cases.
If as a developer I want this feature I'm not sure why I wouldn't just stick a "retry" annotation somewhere in the function declaration (schema file, export, whatever.) I can see the utility of having the RPC layer handle this for me, particularly for pure compute functions. That's "good enough" error handling: the developer correctly identifying which functions are retryable, erring on the side of caution, and getting automatic retries for those (and just those.) Other RPC errors bubble up.
What benefit AI gives here — especially in this form, hidden in the RPC layer — I don't see at all. If I want AI to help me identify which functions are retryable, I'd rather have it do that in my editor by visibly sticking the "retry" attribute on the function. That way I can fix it if it mis-guesses.
Also: what do you do if with your RPC implementation the guess is wrong and a function is retried when it really shouldn't be? What's the fix?
It is a global switch per cluster, yes. Agree that it should be a per-function property, and we're working towards that. It's currently in beta.
> What benefit AI gives here — especially in this form, hidden in the RPC layer — I don't see at all. If I want AI to help me identify which functions are retryable, I'd rather have it do that in my editor by visibly sticking the "retry" attribute on the function. That way I can fix it if it mis-guesses.
I think you're mistaking "identifying functions" with "identifying failures". The AI does not identify which functions are retryable. That's your job as a developer. The AI helps with figuring out which *failures* are retryable.
You can't potentially account for all retryable cases in your code. Some exceptions happen in underlying libraries, database drivers and OS level that you might not have see before.
ECONNRESET? Yes ECONNREFUSED? Yes 429? Yes 400? No DatabaseDeadlockError? Yes PGPoolConnExhausted? Yes
> Also: what do you do if with your RPC implementation the guess is wrong and a function is retried when it really shouldn't be? What's the fix?
Good question. If there's a function that you definitely can't afford to retry, there's an idempotence helper [1]
[1] https://docs.differential.dev/advanced/idempotency/
edit: typo
RPC, even if running on the same machine, is distributed systems land.
I think it's a distributed language runtime where you write functions in typescript and the runtime deals with passing data between machines.
The website is quite good at presenting the system as a nice thing that does nice things and you should like it and it's all very nice. It does a very poor job of convincing me that it works properly. I'd want to know how the scheduler works and how it handles mutable state in the presence of network partitions.
Also just found a caveat which amounts to they've got the implementation wrong:
> Arguments must be JSON serializable. This means that you can pass strings, numbers, booleans, arrays, objects, and null. You cannot pass functions, promises, or other non-serializable objects
> It does a very poor job of convincing me that it works properly. I'd want to know how the scheduler works and how it handles mutable state in the presence of network partitions.
Thank you. This is valuable feedback, and will definitely work this in to the docs.
The current pages are a strong sales pitch to semi-technical management. Look at all the things you don't have to implement!
I read this looking for indications that you've built the complicated thing correctly. Do you understand the maths involved, have you implemented it in a fashion that inspires confidence.
A distributed language runtime that works properly is a valuable thing. One that kind-of works when held carefully is a liability that people would regret trying to build on.
Functions are serializable. And deserializable. You can absolutely take one defined on one machine, kick it over the wire, then execute it on another one. Likewise closures, you serialise the associated state as well.
Promises are the same thing - a distributed language runtime should be exactly the sort of graph execution system which lets you pass promises between machines and have things work out.
Further, they don't say what other "non-serializable" things are. Is a DAG serialisable without spuriously unrolling it into a tree and failing to fold back into a DAG at the other end? How about a graph? Given that all things are serializable it is difficult to guess what things they haven't implemented.
So by "they've got the implementation wrong", I'm saying they haven't implemented the tricky part of serialisation, only the copy ints over wires part. And by "wrong", I'm saying that a language runtime dedicated to transparently running typescript functions on other machines should be able to run those functions on other machines even if they have closed over state.
Maybe the line could be written better. It is supposed to say: You can't pass functions and promises. And you can't pass in other data types that are not serialisable.
I definitely did not intend to say that functions or promises are not serialisable, and it is something we're looking into. The complexity is with serialising the closure state.
The other thing we're implementing is constraining the data types via the type system itself.
edit: punctuation
But I'm still confused:
>Monolithic codebases don't have to result in monolithic services.
Why would I want to replace straighforward function calls with network calls in my monolith?
>By using a centralised control-plane, Differential transparently handles network faults and machine restarts with retries, all without changing your existing programming paradigm. It is designed to be a drop-in replacement for any function call that you'd like to make distributed and reliable.
"Centralization" and "reliability" don't sound like words that often come together. What if the control plane goes down? Unless they have a cluster? It's all self-imposed problems anyway: if we don't have network calls in the monolith, we don't have all those problems in the first place (which need to be solved with retries etc.)
> Why would I want to replace straighforward function calls with network calls in my monolith?
I agree that there's nothing inherently virtuous with replacing a functioning local call with a remote procedure call. But if you decide to break your monolith up for any one of the reasons people tend to follow service-oriented architecture, then Differential reduces the friction.
Here are our thoughts on this: https://docs.differential.dev/advanced/soa/
> "Centralization" and "reliability" don't sound like words that often come together. What if the control plane goes down? Unless they have a cluster?
Yes, there's a cluster.
You demonstrate a lack of understanding of idempotence on your marketing page, which is enough to dismiss your service outright. With all due respect, I'm sure you've put a ton of work into this, and you may even manage to sell it to some teams, but this has been tried and failed so many times in software development's history. It won't be any different now. This is very likely to cause long term harm to any team that adopts it.
For anyone considering it, please make sure you actually understand idempotence and autonomy. Look into event sourcing. Study the fallacies of distributed computing. Check out the work of Udi Dahan and Scott Bellware. Run, do not walk from anything purporting to do the things that this does.
> As many of the other comments here have said, this has been done before. You are repeating the mistakes of DCOM and gussying it up with a modern-looking marketing page.
Respectfully disagree, it's not really comparable to DCOM and CORBA. It contains a control plane which is stateful [1]. CORBA does have an ORB [2], which is close, but the specification does not allow for durability.
I do apologise for having a modern looking marketing page.
> You demonstrate a lack of understanding of idempotence on your marketing page, which is enough to dismiss your service outright.
I think we discussed this elsewhere in the thread where I gave you the implementation details that prove the claims of the marketing page.
> With all due respect, I'm sure you've put a ton of work into this, and you may even manage to sell it to some teams, but this has been tried and failed so many times in software development's history. It won't be any different now. This is very likely to cause long term harm to any team that adopts it.
It's actually open-source [4] and self-hostable, so teams don't have to "buy" it. I admire you confidence about this failing, and you might be right. But the reason why this has been tried before in the software development history tells me that the proper abstraction is somewhere out there. If everyone resorted to not trying something that failed before from a new perspective, we probably wouldn't be very successful as a species. Everything is a remix, after all.
> For anyone considering it, please make sure you actually understand idempotence and autonomy. Look into event sourcing. Study the fallacies of distributed computing. Check out the work of Udi Dahan and Scott Bellware. Run, do not walk from anything purporting to do the things that this does.
Wise words, but I'd appreciate it if you could dive into the way things are [1] [3] a little bit, and let me know if you hold the same views.
[1] https://docs.differential.dev/advanced/architecture/
[2] https://www.sciencedirect.com/topics/computer-science/object...
It would require some client support, though. Alternatively, if the RPCs have the same arguments, the framework could choose to ignore seemingly identical ones, though that has its own issues.
If the framework records the occurrence of the call before the effect of the function, you achieve at-most-once semantics. If it records the call after the effect, you get at-least-once.
The framework might perform its idempotency bookkeeping within the same transaction boundary as the function's side-effects, but this means the function implementation is no longer a black-box. E.g. you can no longer perform arbitrary side-effects while preserving the idempotency guarantees of the framework.
> If a machine fails to send any heartbeats within an interval (default 90 seconds):
> It is marked as unhealthy, and Differential will not send any new requests to it.
> The functions in progress are marked as failed, and Differential will retry them on a healthy worker.
I would guess that “idempotent” functions in the system also take a lease out on the idempotency key. Perhaps they release the lease on failure since they can observe errors thrown, and they commit the key as consumed after success. ¯\_(ツ)_/¯ the docs are not clear on these semantics!
If it's the case that the idempotency wrapper is only for operations that are already idempotent, it makes me wonder that the docs couldn't do a better job of communicating the purpose and function. Decorate your idempotent operations.. to make them more idempotent?
The control-plane intercepts that and implements idempotence for you.
In distributed systems, the reason idempotency is such a Big Deal™ is that it can be combined with at-least-once delivery to achieve exactly-once semantics. This isn't that. What you're describing as idempotency has the potential to mislead users, especially since you use examples like credit card processing.
You might be on to something here:
> Maybe describe it as a retry policy, or as a choice between at-least-once and at-most-once
and we will consider changing it because I agree that conflating the concepts (or the appearance thereof) is not worth diluting the other parts of the offering.
I still struggle to find the difference between this approach and the likes of Stripe [1] and Temporal [2] because in practice, it yields the same result.
[1] https://docs.stripe.com/api/idempotent_requests
[2] https://www.restack.io/docs/temporal-knowledge-temporal-io-i...
Doesn't seem like a big issue to me.
You can use normal code on top of this to solve the bigger problems.
Any exception eventually bubbles up to the caller, who can handle this in a try/catch.
Or like rspc (in Rust) https://www.rspc.dev/
It _does_ put an extra hop in your network calls, but it allows some the benefits of orchestration.
Here's an opinionated take: https://docs.differential.dev/getting-started/thinking/
I agree that it limits the usage of the tool in a polygot environment. I disagree it's a downside.
The absence of an intermediary language does give some benefits to the first class citizen (in this case, Typescript).
However, there are some other developments [1] which attempt to make the Typescript type system an IDL to allow for better interop.
If your IDL isn't a first-class citizen then what do you expect the derivatives to be?
But I think it's a little dangerous to market this as "feels like local functions". It glosses over a lot of really important technical considerations (like, the network and all the dragons that come with it) which will eventually bite people who don't understand that, and will immediately turn people off who do understand that.
I'm not a marketing or copy expert by any means, but what might be a neat product is (rightfully) getting criticized in the comments here for the positioning.
Completely agree. To be honest, we didn't intend to have this many eyes on the product as we're still iterating (both the abstraction and the copy).
We've gone through a lot of iterations on the copy itself, and I agree that there might be a better framing here which works.
It seems a bit of a chicken and egg in this case.
A service needs to register itself with a control plane. But for the service to start it needs to get a request (via lambda invocation).
> But for the service to start it needs to get a request (via lambda invocation).
A service can also start by manually `.invoke`-ing the lambda.
The control-plane will start the lambda function when there's work. Lambda "asks" for work to do. Once work has finished, lambda function exits.
When deploying, we start the lambda function once so it can come out for air and advertise itself to the control-plane.
This is an affordance we do only do for lambda, and currently in development with our deployment offering here [1]
[1] https://github.com/differentialhq/differential/blob/236ffc53...
Ok, this blew up, and I appreciate the engagement. We will attempt to get to all the questions.
We are still polishing the initial offering, so if the documentation seems lacking, it's because it very much is so. Honestly, we did not anticipate having this many eyes on the project this early.
Thanks for the feedback on the use-cases. Will work that into the website.
In the meantime, here's a write up on our value prop: https://docs.differential.dev/getting-started/thinking/
We've been a bunch of devs hacking together on this for a few months (~6). And we definitely haven't had the blessing (or the curse) of ZIRP.
"Kids , get off my lawn."
"Sir, its The Fallacies of Distributed Computing for you, on line 1!"
So, I'm happy to leave it here and wish you a good day.
[1] https://en.wikipedia.org/wiki/Fallacies_of_distributed_compu...
[1] https://docs.differential.dev/advanced/comparisons/#comparis...