Re: [PHP] PHP connection to external application
On 6/13/08, Per Jessen [EMAIL PROTECTED] wrote: hce wrote: I am not certain if the msg_send / msg_receive in PHP can talk to the external C program msg_send / msg_receive as PHP and external C program are in different processes, different memory spaces. System V message queues are intended for just that; IPC = Inter Process Communication. (a) A simple way is if for every PHP request, it opens socket, sends a request and gets a response from the C server then closes the socket. It should work, but I am not sure: (i) if the open / close socket per request will cause delays and performance issues. They will cause both delays and performance issues. But whether these will matter for your use is a different question. The process you've describe (open,get,close) is no different to sending an email or getting a web-page. People send a lot of email and serve a lot of webpages without major performance issues :-) (ii) What is the maximum number concurrent requests in a PHP web application? That's up to your webserver - if it's big enough, you can serve a lot of concurrent requests. Will the maximum socket number / or port number (up to 2^16) be a bottleneck for large number of concurrent requests (hundred and thousands)? Probably not. (b) If for all PHP requests share only one socket to connect to the external C server, I am not sure if the PHP is able to do multiplex responses for each request as the PHP is stateless. PHP is stateless ?? PHP is a scripting language, not a protocol. Besides, it would take quite a bit of work to make your thousands of concurrent PHP requests share a single socket. Sorry for not being clear here. I was saying PHP web application is stateless, not the PHP. You are right, it would take more efforts to use the share a single socket. It is not an option. Anyway, thanks for all your responses and suggestions. It was good suggestion to use SOAP and Web services, but we have very small latency requirement, I have already worried about the delay in the lower level of socket, it will be evern more processing delays for useing SOAP and Web services. I'll keep eye on that option if our processing delay requirement can be altered. Thank you. Kind Regards,. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
hce wrote: Anyway, thanks for all your responses and suggestions. It was good suggestion to use SOAP and Web services, but we have very small latency requirement, I have already worried about the delay in the lower level of socket, it will be evern more processing delays for useing SOAP and Web services. Agree - it's only extra overhead. Jim, if I were you, I'd go for the socket-communication, i.e. TCP. That setup is being used for all kinds of stuff - unless your latency requirements are extreme, I think TCP will be fine. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
On 6/14/08, Per Jessen [EMAIL PROTECTED] wrote: hce wrote: Anyway, thanks for all your responses and suggestions. It was good suggestion to use SOAP and Web services, but we have very small latency requirement, I have already worried about the delay in the lower level of socket, it will be evern more processing delays for useing SOAP and Web services. Agree - it's only extra overhead. Jim, if I were you, I'd go for the socket-communication, i.e. TCP. That setup is being used for all kinds of stuff - unless your latency requirements are extreme, I think TCP will be fine. Thanks Per. Yes, I'll indeed use the socket connection which will be the minimum process delays and overheads I can get. In option 2 you responsed: System V message queues are intended for just that; IPC = Inter Process Communication. The delays and overheads in message queue (in my option 2) may be smaller than the socket, but I guess that might require the external C server to be compiled with the PHP module as they are totally seperated. Thank you. Kind Regards. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
hce wrote: I am not certain if the msg_send / msg_receive in PHP can talk to the external C program msg_send / msg_receive as PHP and external C program are in different processes, different memory spaces. System V message queues are intended for just that; IPC = Inter Process Communication. (a) A simple way is if for every PHP request, it opens socket, sends a request and gets a response from the C server then closes the socket. It should work, but I am not sure: (i) if the open / close socket per request will cause delays and performance issues. They will cause both delays and performance issues. But whether these will matter for your use is a different question. The process you've describe (open,get,close) is no different to sending an email or getting a web-page. People send a lot of email and serve a lot of webpages without major performance issues :-) (ii) What is the maximum number concurrent requests in a PHP web application? That's up to your webserver - if it's big enough, you can serve a lot of concurrent requests. Will the maximum socket number / or port number (up to 2^16) be a bottleneck for large number of concurrent requests (hundred and thousands)? Probably not. (b) If for all PHP requests share only one socket to connect to the external C server, I am not sure if the PHP is able to do multiplex responses for each request as the PHP is stateless. PHP is stateless ?? PHP is a scripting language, not a protocol. Besides, it would take quite a bit of work to make your thousands of concurrent PHP requests share a single socket. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
hce wrote: Let me first describe the requirement more: The C program is a major business server I would not connect applications on low level. I would think of a web services type of interface - http request and xml response (Steven suggested, for example, SOAP - but it does not need to be that complicated). The has several benefits - a) Clearly defined, the web services gate will not be affected by changes in the C program. b) You can use the web services gate to plug not only your php application, but any other application that can (be made to) talk web services. c) The implementation of the php application, in this case, will be trivial, resulting in cheaper developers/development/maintenance/expansion. (ii) What is the maximum number concurrent requests in a PHP web application? Will the maximum socket number / or port number (up to 2^16) be a bottleneck for large number of concurrent requests (hundred and thousands)? Nobody can tell you this for your existing infrastructure. The only thing you can do is try and optimize. Iv -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP connection to external application
Hi, What is the best way for a PHP web application to connect to an external application written by C in Linux OS? (1) Can PHP directly call external C functions, or similar solution? (2) Can PHP pass messages to message queue which external C program can access? (3) Socket connection between the PHP and externam C program. Thank you. Kind Regards, Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
On Thu, 2008-06-12 at 21:20 +1000, hce wrote: Hi, What is the best way for a PHP web application to connect to an external application written by C in Linux OS? (1) Can PHP directly call external C functions, or similar solution? (2) Can PHP pass messages to message queue which external C program can access? (3) Socket connection between the PHP and externam C program. Thank you. If that C program can support SOAP calls ... then that will probably be the best route for you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
On 12 Jun 2008, at 12:20, hce wrote: What is the best way for a PHP web application to connect to an external application written by C in Linux OS? (1) Can PHP directly call external C functions, or similar solution? No, but you can wrap the C functions in a PHP extension. (2) Can PHP pass messages to message queue which external C program can access? Depends on the implementation of the queue, but the answer is almost certainly yes. (3) Socket connection between the PHP and externam C program. This would usually be my preferred choice unless there is a particular reason to avoid this in which case I would go down the PHP extension route. A lot will depend on what the C code is doing and how your PHP scripts will interact with it. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
hce wrote: What is the best way for a PHP web application to connect to an external application written by C in Linux OS? (1) Can PHP directly call external C functions, or similar solution? PHP can call external executables via e.g. exec(). (2) Can PHP pass messages to message queue which external C program can access? PHP can write to a FIFO / pipe. (3) Socket connection between the PHP and externam C program. Yes, that works too. What is the best depends on your requirements. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP connection to external application
On Thu, Jun 12, 2008 at 9:30 PM, Stut [EMAIL PROTECTED] wrote: On 12 Jun 2008, at 12:20, hce wrote: What is the best way for a PHP web application to connect to an external application written by C in Linux OS? (1) Can PHP directly call external C functions, or similar solution? No, but you can wrap the C functions in a PHP extension. Ok, that is not an option. (2) Can PHP pass messages to message queue which external C program can access? Depends on the implementation of the queue, but the answer is almost certainly yes. I am not certain if the msg_send / msg_receive in PHP can talk to the external C program msg_send / msg_receive as PHP and external C program are in different processes, different memory spaces. Unless wrap the C functions in a PHP extension as your suggested in (1). (3) Socket connection between the PHP and external C program. This would usually be my preferred choice unless there is a particular reason to avoid this in which case I would go down the PHP extension route. A lot will depend on what the C code is doing and how your PHP scripts will interact with it. Let me first describe the requirement more: The C program is a major business server which accesses the database, exchanges information to other remote servers and it has many other background tasks running concurrently for doing monitor, statistic report, real time update data, etc. The PHP web application connects to the C program to get data and information and to display on user's web browser. I know socket works between the PHP and external C server, but there are many concerns depends on different implementations: (a) A simple way is if for every PHP request, it opens socket, sends a request and gets a response from the C server then closes the socket. It should work, but I am not sure: (i) if the open / close socket per request will cause delays and performance issues. (ii) What is the maximum number concurrent requests in a PHP web application? Will the maximum socket number / or port number (up to 2^16) be a bottleneck for large number of concurrent requests (hundred and thousands)? (b) If for all PHP requests share only one socket to connect to the external C server, I am not sure if the PHP is able to do multiplex responses for each request as the PHP is stateless. Thank you. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php