Discussion - PHP with distributed programming features.

php.internals

juan carlos morales

2 years ago
Imagine a request comes to NgInx, then we process the request in PHP .... suddenly while execution of PHP is running, we dont have more resources in the server , so we need to process that PHP code on other server with more resources. How can we "move" the complete PHP process to another server with more resources and then send back the result ? this is like having a distributed php infrastructure, behaving in a dynamic way. how can we achieve something like this? or maybe one piece of code needs to run in another server because of resources or something like that, like a function for example, only running one function in a different host and then come back to the mother one. My question is .... what do we need to provide PHP some functionality like the distributed programming languages? It could be achieve with long running PHP instances and using MPI for example (I imagine) but ... ideas on this ? Maybe I am crazy

Robert Landers

2 years ago
On Fri, Oct 27, 2023 at 1:38 PM juan carlos morales <dev.juan.morales@gmail.com> wrote:
> > Imagine a request comes to NgInx, then we process the request in PHP > .... suddenly while execution of PHP is running, we dont have more > resources in the server , so we need to process that PHP code on other > server with more resources. > > How can we "move" the complete PHP process to another server with more > resources and then send back the result ? > > this is like having a distributed php infrastructure, behaving in a dynamic way. > > how can we achieve something like this? > > or maybe one piece of code needs to run in another server because of > resources or something like that, like a function for example, only > running one function in a different host and then come back to the > mother one. > > My question is .... what do we need to provide PHP some functionality > like the distributed programming languages? > > It could be achieve with long running PHP instances and using MPI for > example (I imagine) but ... ideas on this ? Maybe I am crazy > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >
You mean, like an API call to an instance running on another machine? I imagine that's the simple, non-technical solution. To what you're imagining (I think), I've been working on DurablePHP (https://github.com/bottledcode/durable-php) which can already kinda do that (using fibers to execute code elsewhere, then return back -- or not). It's nowhere near production-ready, but its a fun project and already running some interesting toy-projects around the house. But it has a number of issues left to iron out (particularly around the serialization of exceptions and migrating workloads from hot-shards). For an MVP/POC of the idea, it works pretty well. Robert Landers Software Engineer Utrecht NL

Кирилл Несмеянов

2 years ago

juan carlos morales

2 years ago
El El vie, 27 de oct. de 2023 a la(s) 10:59, Kirill Nesmeyanov < nesk@xakep.ru> escribió:
> > >Пятница, 27 октября 2023, 14:38 +03:00 от juan carlos morales < > dev.juan.morales@gmail.com>: > > > >Imagine a request comes to NgInx, then we process the request in PHP > >.... suddenly while execution of PHP is running, we dont have more > >resources in the server , so we need to process that PHP code on other > >server with more resources. > > > >How can we "move" the complete PHP process to another server with more > >resources and then send back the result ? > > > >this is like having a distributed php infrastructure, behaving in a > dynamic way. > > > >how can we achieve something like this? > > > >or maybe one piece of code needs to run in another server because of > >resources or something like that, like a function for example, only > >running one function in a different host and then come back to the > >mother one. > > > >My question is .... what do we need to provide PHP some functionality > >like the distributed programming languages? > > > >It could be achieve with long running PHP instances and using MPI for > >example (I imagine) but ... ideas on this ? Maybe I am crazy > > > >-- > >PHP Internals - PHP Runtime Development Mailing List > >To unsubscribe, visit: https://www.php.net/unsub.php > > Hello! > > nginx connects to fpm using the fcgi protocol via sockets. All you need to > do is create a socket with roundrobin (or like that), which will delegate > the request to a specific fpm socket. > > Or don’t reinvent the wheel, since nginx itself copes with this (with > balancing) perfectly in reverse proxy mode =)) > > -- > Kirill Nesmeyanov >
What I mean is more about … migrating a running php instance to another node or another php instance, in fact your php code is running, suddenly we Need to move to another node, how to do it?

Jordan LeDoux

2 years ago
On Sat, Oct 28, 2023 at 10:54 AM juan carlos morales < dev.juan.morales@gmail.com> wrote:
> > > What I mean is more about … migrating a running php instance to another > node or another php instance, in fact your php code is running, suddenly we > Need to move to another node, how to do it? >
This seems less like a discussion about a PHP feature and more like you asking internals for tech support at work, honestly. As far as I know, there isn't a way to do what you're asking, because you can accomplish the same thing much easier by designing your application better to make API calls to services, which is what people have already suggested. The PHP way to handle the root cause of your problem (too many resources being used on a single machine) is to divide the application into services and use APIs, often through sockets, the delegate work to those services. There are also other ways of handling this common problem in web application architecture. You can break up the request into multiple requests on the client side so that the user sees progress happen in chunks. You can use tools like RabbitMQ or other queuing services to perform certain long-running tasks asynchronously. You can use more powerful hardware or provision more capable nodes. In fact, several of these actually fall under the Actor/Object or Dataflow model of implementing Distributed Programming. What PHP does not support is the Distributed Shared Memory model of implementing Distributed Programming (which is what you are asking about apparently) because doing so would almost certainly make PHP worse at the things it is well suited for, would massively complicate the work of maintaining and developing the language for the contributors to the language, and would be a massive undertaking to implement in the first place. PHP has distributed programming features. In fact, all of the suggestions you have received so far ARE ways of doing distributed programming features. But internals is not your, or my, or anyone else's personal tech support channel, and personally it feels like you haven't explained what it is you want to discuss with internals about improving or changing PHP's support for distributed programming. Are you interested in working on an RFC to clone a PHP process onto a remote box? I can't imagine that would get much support here, or be something that is very simple to do. Jordan

juan carlos morales

2 years ago
El El sáb, 28 de oct. de 2023 a la(s) 19:25, Jordan LeDoux < jordan.ledoux@gmail.com> escribió:
> > > On Sat, Oct 28, 2023 at 10:54 AM juan carlos morales < > dev.juan.morales@gmail.com> wrote: > >> >> >> What I mean is more about … migrating a running php instance to another >> node or another php instance, in fact your php code is running, suddenly >> we >> Need to move to another node, how to do it? >> > > This seems less like a discussion about a PHP feature and more like you > asking internals for tech support at work, honestly. As far as I know, > there isn't a way to do what you're asking, because you can accomplish the > same thing much easier by designing your application better to make API > calls to services, which is what people have already suggested. The PHP way > to handle the root cause of your problem (too many resources being used on > a single machine) is to divide the application into services and use APIs, > often through sockets, the delegate work to those services. > > There are also other ways of handling this common problem in web > application architecture. You can break up the request into multiple > requests on the client side so that the user sees progress happen in > chunks. You can use tools like RabbitMQ or other queuing services to > perform certain long-running tasks asynchronously. You can use more > powerful hardware or provision more capable nodes. > > In fact, several of these actually fall under the Actor/Object or Dataflow > model of implementing Distributed Programming. What PHP does not support is > the Distributed Shared Memory model of implementing Distributed Programming > (which is what you are asking about apparently) because doing so would > almost certainly make PHP worse at the things it is well suited for, would > massively complicate the work of maintaining and developing the language > for the contributors to the language, and would be a massive undertaking to > implement in the first place. > > PHP has distributed programming features. In fact, all of the suggestions > you have received so far ARE ways of doing distributed programming > features. But internals is not your, or my, or anyone else's personal tech > support channel, and personally it feels like you haven't explained what it > is you want to discuss with internals about improving or changing PHP's > support for distributed programming. Are you interested in working on an > RFC to clone a PHP process onto a remote box? I can't imagine that would > get much support here, or be something that is very simple to do. > > Jordan >
>
Hello Jordan, thanks for the reply. When I read you, I have the feeling that you are a little angry about my question, please dont. It is a very honest question, that do belong to the internals, because if PHP does not have a way to do it, I would like to think a way to do it (despite the fact someone believes is useful or not, it is just me). So again, thanks!, dont get mad :D, and I will come back later on this topic, in a more clear way, maybe I am not expressing myself clearly. Regards

Jordan LeDoux

2 years ago
On Sat, Oct 28, 2023 at 4:35 PM juan carlos morales < dev.juan.morales@gmail.com> wrote:
> > > El El sáb, 28 de oct. de 2023 a la(s) 19:25, Jordan LeDoux < > jordan.ledoux@gmail.com> escribió: > >> >> >> On Sat, Oct 28, 2023 at 10:54 AM juan carlos morales < >> dev.juan.morales@gmail.com> wrote: >> >>> >>> >>> What I mean is more about … migrating a running php instance to another >>> node or another php instance, in fact your php code is running, suddenly >>> we >>> Need to move to another node, how to do it? >>> >> >> This seems less like a discussion about a PHP feature and more like you >> asking internals for tech support at work, honestly. As far as I know, >> there isn't a way to do what you're asking, because you can accomplish the >> same thing much easier by designing your application better to make API >> calls to services, which is what people have already suggested. The PHP way >> to handle the root cause of your problem (too many resources being used on >> a single machine) is to divide the application into services and use APIs, >> often through sockets, the delegate work to those services. >> >> There are also other ways of handling this common problem in web >> application architecture. You can break up the request into multiple >> requests on the client side so that the user sees progress happen in >> chunks. You can use tools like RabbitMQ or other queuing services to >> perform certain long-running tasks asynchronously. You can use more >> powerful hardware or provision more capable nodes. >> >> In fact, several of these actually fall under the Actor/Object or >> Dataflow model of implementing Distributed Programming. What PHP does not >> support is the Distributed Shared Memory model of implementing Distributed >> Programming (which is what you are asking about apparently) because doing >> so would almost certainly make PHP worse at the things it is well suited >> for, would massively complicate the work of maintaining and developing the >> language for the contributors to the language, and would be a massive >> undertaking to implement in the first place. >> >> PHP has distributed programming features. In fact, all of the suggestions >> you have received so far ARE ways of doing distributed programming >> features. But internals is not your, or my, or anyone else's personal tech >> support channel, and personally it feels like you haven't explained what it >> is you want to discuss with internals about improving or changing PHP's >> support for distributed programming. Are you interested in working on an >> RFC to clone a PHP process onto a remote box? I can't imagine that would >> get much support here, or be something that is very simple to do. >> >> Jordan >> > >> > Hello Jordan, thanks for the reply. When I read you, I have the feeling > that you are a little angry about my question, please dont. > > It is a very honest question, that do belong to the internals, because if > PHP does not have a way to do it, I would like to think a way to do it > (despite the fact someone believes is useful or not, it is just me). > > So again, thanks!, dont get mad :D, and I will come back later on this > topic, in a more clear way, maybe I am not expressing myself clearly. > > Regards >
I'm not angry at all, I just wanted to focus in on a discussion that is relevant to the internals mailing list. Most of the ideas here, including the ones I've proposed, come from our own experiences and there's nothing wrong with that. But I didn't see anything that looked like a discussion and I wanted to be clear about what I think this list is for, and what kind of discussions might be productive. I don't think that what you are talking about would be very useful, because I expect that it would be complicated for very little benefit. But if you think this is a way to improve the language, then I would listen. I just wasn't hearing that. It is also possible I am not understanding very well. Jordan