Quantcast

PHP Service Efficiency

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PHP Service Efficiency

bilbosax
This is just a little theoretical question I have wondered about, so I thought I would ask it here.  I am writing an app that I hope will have at least 10k users daily.  When you set up your services, you can technically put them all in a single PHP file if you want to, or spread them out across several files that are more specific, however you want to do it.  But I am curious, if I have 10k users trying to access a single PHP file instead of having the workload spread across several PHP files, will this cause a bottleneck, and will I lose efficiency.

I have no idea how PHP handles multiple users.  Does anybody know if the workload will be handled more efficiently if the PHP services are spread across multiple files rather than one big one?

Thanks for any insight.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PHP Service Efficiency

Fréderic Cox
I think this is a question that is better suited for stackoverflow.

On Tue, Apr 11, 2017 at 3:21 AM, bilbosax <[hidden email]> wrote:

> This is just a little theoretical question I have wondered about, so I
> thought I would ask it here.  I am writing an app that I hope will have at
> least 10k users daily.  When you set up your services, you can technically
> put them all in a single PHP file if you want to, or spread them out across
> several files that are more specific, however you want to do it.  But I am
> curious, if I have 10k users trying to access a single PHP file instead of
> having the workload spread across several PHP files, will this cause a
> bottleneck, and will I lose efficiency.
>
> I have no idea how PHP handles multiple users.  Does anybody know if the
> workload will be handled more efficiently if the PHP services are spread
> across multiple files rather than one big one?
>
> Thanks for any insight.
>
>
>
> --
> View this message in context: http://apache-flex-users.
> 2333346.n4.nabble.com/PHP-Service-Efficiency-tp15015.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PHP Service Efficiency

Jeffry Houser

  It is not really a Flex question, so I generally agree.

  My expectation is that PHP will be able to handle multiple threads /
concurrent requests [just like most other server side software I've
used].  At certain traffic limitations you may need to use a more
powerful server, or even multiple servers to prevent things from getting
overloaded.

  It seems unlikely to me that you'll have 10K users accessing the same
service simultaneously, but it depends on the app your user base and the
success of the venture.


On 4/11/2017 6:55 AM, Fréderic Cox wrote:

> I think this is a question that is better suited for stackoverflow.
>
> On Tue, Apr 11, 2017 at 3:21 AM, bilbosax <[hidden email]> wrote:
>
>> This is just a little theoretical question I have wondered about, so I
>> thought I would ask it here.  I am writing an app that I hope will have at
>> least 10k users daily.  When you set up your services, you can technically
>> put them all in a single PHP file if you want to, or spread them out across
>> several files that are more specific, however you want to do it.  But I am
>> curious, if I have 10k users trying to access a single PHP file instead of
>> having the workload spread across several PHP files, will this cause a
>> bottleneck, and will I lose efficiency.
>>
>> I have no idea how PHP handles multiple users.  Does anybody know if the
>> workload will be handled more efficiently if the PHP services are spread
>> across multiple files rather than one big one?
>>
>> Thanks for any insight.
>>
>>
>>
>> --
>> View this message in context: http://apache-flex-users.
>> 2333346.n4.nabble.com/PHP-Service-Efficiency-tp15015.html
>> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>>

--
Jeffry Houser
Technical Entrepreneur
http://www.jeffryhouser.com
203-379-0773

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PHP Service Efficiency

bilbosax
Thanks for the reply guys. I would have taken it over to stackoverflow, but they do not take kindly to theoretical questions. If there is no code attached, they can be ruthless. I only asked here because they are Flex services that I am designing, and that is about the extent of my PHP knowledge.

From what I have found, it sounds like personal preference, both approaches work. Some argue that it comes down to code readability and maintenance. The most compelling argument that I read, and the one that I am going to use, is file size. If you have a big 6MB PHP file being loaded for thousands of users at a time, this could effect performance, whereas if you have several 50k service files, the server can handle it better.

So I think I am going to go with several small service files rather than one big one. Personal choice.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PHP Service Efficiency

Tom Chiverton
In reply to this post by Jeffry Houser
If you really do need 10k simultaneous calls, you will be having a
cluster of servers :-)

So the efficiency of a single one isn't as important.

And a better organised set of files in the service will help maintenance
and bug fixing.

Tom


On 11/04/17 15:33, Jeffry Houser wrote:

>
>  It is not really a Flex question, so I generally agree.
>
>  My expectation is that PHP will be able to handle multiple threads /
> concurrent requests [just like most other server side software I've
> used].  At certain traffic limitations you may need to use a more
> powerful server, or even multiple servers to prevent things from
> getting overloaded.
>
>  It seems unlikely to me that you'll have 10K users accessing the same
> service simultaneously, but it depends on the app your user base and
> the success of the venture.
>
>
> On 4/11/2017 6:55 AM, Fréderic Cox wrote:
>> I think this is a question that is better suited for stackoverflow.
>>
>> On Tue, Apr 11, 2017 at 3:21 AM, bilbosax <[hidden email]>
>> wrote:
>>
>>> This is just a little theoretical question I have wondered about, so I
>>> thought I would ask it here.  I am writing an app that I hope will
>>> have at
>>> least 10k users daily.  When you set up your services, you can
>>> technically
>>> put them all in a single PHP file if you want to, or spread them out
>>> across
>>> several files that are more specific, however you want to do it.  
>>> But I am
>>> curious, if I have 10k users trying to access a single PHP file
>>> instead of
>>> having the workload spread across several PHP files, will this cause a
>>> bottleneck, and will I lose efficiency.
>>>
>>> I have no idea how PHP handles multiple users.  Does anybody know if
>>> the
>>> workload will be handled more efficiently if the PHP services are
>>> spread
>>> across multiple files rather than one big one?
>>>
>>> Thanks for any insight.
>>>
>>>
>>>
>>> --
>>> View this message in context: http://apache-flex-users.
>>> 2333346.n4.nabble.com/PHP-Service-Efficiency-tp15015.html
>>> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>>>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AW: PHP Service Efficiency

Krüger, Olaf
In reply to this post by bilbosax
I'm not sure but I could imagine if the compiled PHP code is cached it doesn't matter.
However, it's always a good idea to use such a cache. I think since PHP 5.5 the ByteCode is cached by default.
You also could use some of the ByteCode caches out there.
If you're not already using PHP7 and expect performance issues you should dare to take the step to PHP7. People say it is x times faster than previous versions.

At least there is the web server which has to handle the concurrent requests!
Depending on the web server this could be done differently and may end up in doing some more investigation to find out what approach fits your need best. (E.g. Apache vs Nginx)

If you're using PHP sessions you also have to take care about PHP session blocking [1][2].

These days it's all about cloud services.
Instead of hosting and maintaining your servers by yourself it could be an option to go with AWS, Azure, google, ... if you need to scale you just have to do some clicks in best case ;-)

So, I would definitely go with separating the code by concerns, it will be much more maintainable.

Just some thoughts... of course, I could be completely wrong ;-)

HTH,
Olaf

[1] https://ma.ttias.be/php-session-locking-prevent-sessions-blocking-in-requests/
[2] http://konrness.com/php5/how-to-prevent-blocking-php-requests/

________________________________

Edscha Holding GmbH
Sitz der Gesellschaft: Remscheid
Registergericht: Wuppertal, HRB 22889
Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña, David Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz und Volker Weiss

Vertretungsberechtigt sind nur Geschäftsführer und schriftlich Bevollmächtigte.

Solely Managing Directors or employees with a written proxy have got power of representation.

Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien ist vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung, Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte informieren Sie in diesem Fall unverzüglich den Absender und löschen Sie die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem System. Vielen Dank.

The contents of this e-mail including any attachments are confidential and may be legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete this e-mail including any attachments from your system. Thank you.
OK
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PHP Service Efficiency

OK
In reply to this post by bilbosax
I'm not sure but I could imagine if the compiled PHP code is cached it doesn't matter.
However, it's always a good idea to use such a cache. I think since PHP 5.5 the ByteCode is cached by default.
You also could use some of the ByteCode caches out there.
If you're not already using PHP7 and expect performance issues you should dare to take the step to PHP7. People say it is x times faster than previous versions.

At least there is the web server which has to handle the concurrent requests!
Depending on the web server this could be done differently and may end up in doing some more investigation to find out what approach fits your need best. (E.g. Apache vs Nginx)

If you're using PHP sessions you also have to take care about PHP session blocking [1][2].

These days it's all about cloud services.
Instead of hosting and maintaining your servers by yourself it could be an option to go with AWS, Azure, google, ... if you need to scale you just have to do some clicks in best case ;-)

So, I would definitely go with separating the code by concerns, it will be much more maintainable.

Just some thoughts... of course, I could be completely wrong ;-)

HTH,
Olaf

[1] https://ma.ttias.be/php-session-locking-prevent-sessions-blocking-in-requests/
[2] http://konrness.com/php5/how-to-prevent-blocking-php-requests/
Loading...