我构建了一个基于Laravel的替代Temporal的方案,仅使用了队列和生成器。

1作者: rmcdaniel7 个月前原帖
我曾在一家金融科技公司工作,我们需要一种方法来跟踪长时间运行的流程。<p>我们使用了排队作业,这些作业会检查之前的步骤是否完成,如果没有完成就会重新排队。虽然这种方法有效,但噪音很大,难以追踪,感觉也不太对劲。<p>于是我开始寻找更好的解决方案。<p>就在这时,我发现了Temporal。他们的PHP SDK提供了很好的开发体验。你可以使用yield来实现异步步骤,像写普通代码一样编写工作流,并且它会从上次中断的地方继续。这种感觉很不错。<p>然后我把这个想法带给了DevOps团队。<p>但遭遇了阻碍。<p>它需要运行一个Kubernetes集群,或者支付他们的云服务费用。他们看着我,似乎在想:“我们为什么要做这些事情来运行PHP作业?”<p>我记得当时心里想着……他们可能是对的。<p>我们已经有了Laravel队列,已经有了数据库。也许我们可以在没有繁琐流程的情况下构建类似的东西。<p>于是我开始动手。<p>我保留了Temporal的PHP SDK中的核心思想,使用yield作为协程的检查点,其他的都抛弃了。不需要服务器,不需要集群,也不需要云服务。<p>一个工作流就是一个排队的作业,它会运行到下一个yield。当yield的作业完成后,它会重新排队工作流,重建状态,并从上次中断的地方继续。<p>这就是概念验证。它成功了。我们将一个基本版本投入了生产。<p>但我无法停止思考这个问题。<p>整个过程就像一个拼图。所以我继续深入,增加了副作用、Saga、子工作流……<p>我把我的私人代码库分享给了我在Temporal结识的一位工程师(因为向他问了太多问题)。<p>他对我说:“哇,这真的很酷。你应该发布它。”<p>于是我就这样做了。写了文档,公开了代码库,标记了composer版本。<p>然后我突然明白了:<p>Temporal并不针对PHP开发者。<p>他们的目标是企业客户,大团队,财富500强公司。<p>他们的PHP SDK虽然在维护,但并不是优先事项。它甚至需要Roadrunner,这是在Temporal服务器之上的额外运行时。这对Laravel开发者来说增加了更多的摩擦。<p>与此同时,我这边则是:<p>没有外部服务 没有自定义运行时 只有队列 + 数据库 还有yield<p>现在,Laravel Workflow悄然成为Laravel中长时间运行的编排的默认选择。<p>它在许多相关短语的Google搜索中名列前茅。<p>Temporal的PHP SDK每天的安装量是我的4-5倍。但他们也获得了3.5亿美元的融资。<p>我通过GitHub赞助商回本了我的域名费用。<p>唯一的“失败”是我没有任何可以出售的东西。没有云产品,也没有SaaS的角度。
查看原文
I was working at a fintech company and we needed a way to track long-running processes.<p>We were using queued jobs that would check if an earlier step had completed, and requeue itself if it hadn&#x27;t. It worked but it was noisy, hard to track, and just felt wrong.<p>I started looking for a better solution.<p>That&#x27;s when I found Temporal. Their PHP SDK had a great developer experience. You could yield async steps, write workflows like regular code, and it just resumed where it left off. It felt right.<p>Then I brought it to the DevOps team.<p>And hit a wall.<p>It required running a k8s cluster or paying for their cloud service. They looked at me like: &quot;Why would we do all this just to run PHP jobs?&quot;<p>And I remember thinking... they&#x27;re probably right.<p>We already had Laravel queues. We already had a database. Maybe we could build something similar without all the ceremony.<p>So I did.<p>I kept the core idea from Temporal&#x27;s PHP SDK, using yield as a coroutine checkpoint, and threw the rest away. No server. No cluster. No cloud.<p>A workflow is just a queued job that runs until the next yield. When the yielded job completes, it requeues the workflow, rebuilds the state, and picks up where it left off.<p>That was the proof of concept. It worked. We shipped a basic version to production.<p>But I couldn&#x27;t stop thinking about it.<p>The whole thing felt like a puzzle. So I kept going, added side effects, sagas, child workflows...<p>I shared my private repo with an engineer I had befriended at Temporal (from bugging him with too many questions).<p>He said: &quot;Wow, that&#x27;s really cool. You should release it.&quot;<p>So I did. Wrote docs. Opened the repo. Tagged a composer release.<p>And then something clicked:<p>Temporal isn&#x27;t targeting PHP devs.<p>They&#x27;re chasing enterprise accounts. Big teams. Fortune 500s.<p>Their PHP SDK is maintained but not a priority. It even requires Roadrunner, an extra runtime on top of the Temporal server. That&#x27;s more friction Laravel devs don&#x27;t want.<p>Meanwhile I&#x27;m over here with:<p>No external services No custom runtimes Just queues + DB And yield<p>Now Laravel Workflow is quietly the default for long-running orchestration in Laravel.<p>It&#x27;s at the top of Google for many relevant phrases.<p>Temporal PHP SDK has 4-5x more daily installs. But they also have $350 million in funding.<p>I&#x27;ve made back my domain name fees with GitHub sponsors.<p>The only &quot;failure&quot; is that I don&#x27;t have anything to sell. There&#x27;s no cloud product. No SaaS angle.