text
stringlengths
0
2.35k
**Anton Titov:** To answer this question, it's actually important to understand how PHP actually became this type of language, and both a language that's hard to scale. Imagine every time you write a Golang application - let's say doing some endpoint in HTTP - every time you get an HTTP request, immediately you have to...
**Johnny Boursiquot:** Mm-hm.
**Anton Titov:** Well, that's how PHP has been working for 26+ years. It's quite amazing that you have the tech which quite literally restarts on every request, and it still kind of powers pretty much the majority of backends on the internet. Well, public backends, let's say.
\[12:07\] So the idea was actually quite simple - let's just remove this overhead. I mean, when I started working with RoadRunner, I started working -- I was actually a protocologist, making communication between the languages. And the first example was quite simple. Let's say we have a function in Golang to do some he...
So then I just tried to make a call from PHP to Golang using this internal socket, or UNIX socket rpc call and it did work. And then I tried to make a very stupid experiment, actually. I tried the native PHP library for RabbitMQ to push message, and I used the Golang library of RabbitMQ to push message, but with additi...
And this kind of led to the idea that -- PHP is a very beautiful language to model business processes. Not like highest-scale IO operations, like traffic management or ingresses. It's single-threaded, it's very dummy, in terms of like it can go left, in can go right in some cases... You still can shoot yourself in the ...
And Golang, on the other side, is beautiful to manage all of these long polling connections, sockets, retries, restarts, delays... All of this fun stuff which PHP, just by definition, by model, can't. So then we tried to create the method, invoking code from PHP's worker pools. So you have like hot processes of PHP, wh...
**Johnny Boursiquot:** Wow.
**Valery Piashchynski:** Yeah, a pretty amazing speech. \[laughs\]
**Johnny Boursiquot:** So who is this for? Is it the Go developer who has to work with PHP, or the PHP developer who has to work with Go, or who are you targeting with this approach.
**Valery Piashchynski:** I guess both of them.
**Anton Titov:** Well, it's actually a very good question. The main audience is obviously PHP people, because the main idea of RoadRunner is you can take these complex aspects of queue load balancing, HTTPS traffic, temporal gRPC, and you're going to make them boring for these developers... But just out of the box. You...
\[16:04\] You have metrics, readiness, healthy endpoints... All the stuff you need to make application, basically like native current environments. But obviously, the first target audience is just engineers and companies who are just trying to write scalable code, but at the same time don't necessarily want to hire ten...
**Johnny Boursiquot:** Okay, so this is as much a technical decision as it is a business one.
**Anton Titov:** Well, in the long-term yes, because how many startups you've seen which come from the point "We're going to scrap out PHP and move to something else"? It's been a bunch. Facebook invented their own language. VKontakte, their Russian competitor, did the same thing. So it's kind of like become so expensi...
**Valery Piashchynski:** Yeah. And at the same time, if you wanted to do some pretty hard work or some low-level stuff, you can easily write a simple plugin, and plug it into RoadRunner, compile it, and solve your needs with that. So we also wrote our own plugin system, because -- so initially, we wanted to use the Gol...
For example, if you write once a configuration parser -- if you write a parser from the Yaml, for example, you don't need to write or copy or create some SDK to bring this part into every plugin. You can just request this init function, and RoadRunner will take care about finding this dependency, initializing it, topol...
If something goes wrong, RoadRunner will take care of this of course, and provide you nice - but unreadable for PHP users - message about some Golang panic, or some error, something like this. And for the PHP -- all the complexity for the PHP is to properly define what do you need in the configuration. You have a confi...
**Anton Titov:** \[20:32\] That's actually quite an exchange of knowledge, because this first container actually came as an architectural pattern in most of the PHP applications... Because if you've seen .NET, Java or PHP applications, you have a ton of classes, interfaces that inherit each other, they use class declar...
**Break:** \[21:33\]
**Johnny Boursiquot:** Let's dive in a little bit, into the weeds, if you will... Are you shipping like a binary? Are you interpreting PHP? If I'm a developer, what does my experience look like?
**Anton Titov:** From a PHP perspective, we're trying to do the least invasive work possible. You literally don't need to do anything to make it work from the PHP side. There's no extensions, there's no special CLIs, interpreters, nothing. What we actually do, we do the 20-30 years old approach, which still drives old ...
\[23:57\] So what RoadRunner does - it actually uses the default PHP interpreter, which is a binary, invokes it with the application, and then keeps its memory in like a pre-warmed state. And when the request payload comes, which can come for HTTP endpoints, task queue, Temporal Workflow, gRPC, whatever, you name it - ...
**Valery Piashchynski:** But surprisingly, RoadRunner knows nothing about the PHP. So RoadRunner is not binded especially to PHP; it just runs some command you specify in your configuration, so you can do it Python... You can ever run Golang inside the Golang workers. So the main purpose for RoadRunner is to manage the...
A project, some guy implemented this protocol in Python. Anton showed me some time ago. So it's Python running inside RoadRunner, because it's pretty much the same model as a one-threaded model in Python. Some guy wrote this, and it works.
**Johnny Boursiquot:** This sounds like a process manager, if you will... So if you wanted to, you could have Python, obviously, as you've just mentioned, Ruby, obviously PHP natively, and whatever else other interpreted languages you want. Even precompiled things, it sounds like you can just have in there, and then ba...
**Anton Titov:** In theory, you can take a 20-year old Perl file and run it on RoadRunner... \[laughter\] But if you want to do it - obviously, that's a good question. But yes, I mean -- I think the main mention of PHP is actually in the title of RoadRunner - it's a PHP application management server. But besides that, ...
**Johnny Boursiquot:** Okay. So if I'm used to working with single-process PHP-style applications - I think you touched on this earlier - where it's like I'm restarting the world, traditionally, when I'm dealing with PHP; one request just restarts the world, and everything is like anew... In this world where instead th...
**Anton Titov:** Well, I mean, when PHP runs at scale, you still have multiple processes. They're just created on demand. But you still have 500 PHP processes running the request. But there is definitely the conception shift in people -- it was really much harder even a year ago, but now... The main reason why it's eas...
\[27:50\] In PHP it's completely different. You have Symfony, Laravel, or our infrastructure framework, Spiral, and they all manage it for you. So the beautiful thing is all of these frameworks, all the time -- well, we created our own, specific for this purpose, but all other frameworks, they actually do upgrades and ...
If you're using a framework which is specifically built for RoadRunner like ours, nothing is different for you. Just write code, and it's all being managed; state is managed in-memory, and all completely resetted.
**Johnny Boursiquot:** So would a PHP developer ever even need to know what's under the hood, what their process is? I assume they'll never really - unless they want to - come in contact with any Go whatsoever.
**Anton Titov:** Well, it's like owning a car and being able to drive a car. If you have RoadRunner and PHP, and a default PHP SDK, you can do many wonderful things. You can PHP respond in like 50 microseconds, run \[unintelligible 00:29:07.27\] and all the queries, use gRPC, and use all of this stuff. But if you also ...
Golang is beautiful, because -- I mean, it's quite easy to learn it, right? It doesn't have many of these legacy overhead nuances you have to remember. So it's not required, but if you do, you're essentially a superhero in PHP world.
**Valery Piashchynski:** Yeah. And also \[unintelligible 00:29:49.23\]
**Anton Titov:** Well, yeah, that's another example how you can use it.
**Valery Piashchynski:** It's also written here, in RoadRunner and PHP combination.
**Anton Titov:** I can show it when it's going to be the right time. Up to you, Johnny.
**Johnny Boursiquot:** Well, given that most of our users are going to be listening, not viewing this, we may not be able to show them much.
**Anton Titov:** I'll try to walk them through, yeah.
**Johnny Boursiquot:** I do want to sort of understand -- obviously, this is an open source project, and folks are contributing to it... I do want to understand what are some of the hardest challenges that you encountered while coming up with this model. Obviously, running a process manager - you have to worry about in...
**Anton Titov:** About the current challenges Valery can speak. I don't think there's a lot of them now, but... When we started working on this though, it's been a number of interesting things to solve. Number one, we had to create a protocol to communicate between two different languages, and it had to work over pipes...
This has been not like a hard conceptual problem, because you can always... Default protocols like a netstrings - you have the lengths of the message, a fixed header size and then you have the payload body. So it's quite easy, you just read the package between languages.
Then obviously it was a problem with the process manager, because PHP sometimes tends not to start if you don't send the right parameters, or it may crash if, again, you send an invalid payload -- I mean, it doesn't do it anymore \[unintelligible 00:31:36.09\] And obviously, race conditions on the Golang side - that wa...
\[32:14\] Or for example you have a request coming, but at the same time the PHP process runs out of the memory. So what's going to happen? It's going to fail. How are you going to restart it? There's been so many little integrational hell and edge cases for this type of work... But eventually, once we jumped from this...
So that was a part of scratching the head a lot, because it was so hard to solve... With all of these dependencies, and plugins, and... Hidden dependencies, because a PHP worker can theoretically do anything it wants; it can call to queue, it can invoke an HTTP endpoint through RoadRunner onto itself, which -- well, I'...
**Johnny Boursiquot:** So if you have this deployed, is it recommended that you have a single tenant kind of situation, whereby you don't want processes from multiple parties that are not really associated with, say, the same company? You don't wanna run this as some sort of an open-to-all, multi-tenant system, because...
**Anton Titov:** Well, it could be. We can isolate it by many different ways. We can isolate them by running with different permission models in PHP. You can literally forbid most of the functions, which - well, some engineers and hackers will still be able to bypass. You can run them in different user groups and in di...
Right now, we don't run it in a shared fashion, old-fashioned shared hosting. It's mostly suitable for the most classic approach now. You have a container, within this container you have the application, your APIs to other service functions of this application. And it's fully self-contained inside this container. If yo...
But I've been thinking about this problem for a while. Basically, in short, if you wanna do multi-tenancy, do it in the application code. RoadRunner is developed/designed to actually work the best in modern Docker environments or container-based environments. It's a single application, pair application instance, let's ...