Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:config:external_application_abort [2019/06/27 13:43]
Jackson Zhang
litespeed_wiki:config:external_application_abort [2019/06/27 15:35]
Lisa Clarke Proofreading
Line 1: Line 1:
-====== ​How to keep script running even the client disconnected? ​====== +====== ​Keep Script Running When Client Disconnects ​====== 
-You may already know [[litespeed_wiki:​php:​run-without-timeouts|how to keep a PHP script running without ​timeout]], however, if the client initiating the long run script breaks a connection with the server, the long run PHP will become idle. LiteSpeed Web Server can automatically abort external application processes generating responses for that client to save server resouces. Some users, however, may have (long-running) processes that they wish to continue ​running ​whether or not the client is still connected. ​''​External Application Abort'' ​setting(LSWS Admin Console-> Configuration-> Server-> General ​-> General Settings ​-> External Application Abort) is just for such need and you can set it to ''​No Abort''​.+You may already know [[litespeed_wiki:​php:​run-without-timeouts|how to keep a PHP script running without ​timing out]], however, if the client initiating the long-running ​script breaks a connection with the server, the PHP will become idle. LiteSpeed Web Server can automatically abort external application processes generating responses for that client to save server resouces. Some users, however, may have (long-running) processes that they wish to continue whether or not the client is still connected. ​The **External Application Abort** setting (found in **LSWS Admin Console > Configuration > Server > General > General Settings**) is meant to address ​such need by setting ​it to ''​No Abort''​.
  
 {{ :​litespeed_wiki:​config:​lsws-external-application-abort.png?​nolink&​800 |}} {{ :​litespeed_wiki:​config:​lsws-external-application-abort.png?​nolink&​800 |}}
  
-There are three options ​for this+**External Application Abort** has three options: 
-  * No Abort: Never abort external applications because of a broken connection. +  * ''​No Abort''​: Never abort external applications because of a broken connection. 
-  * Enable Abort for Requests from External IPs: Only processes started by requests from external IPs will be automatically aborted because of a broken connection. This is the default setting. It is a good setting if you have some internal long-running processes, like some cron jobs. +  * ''​Enable Abort for Requests from External IPs''​: Only processes started by requests from external IPs will be automatically aborted because of a broken connection. This is the default setting. It is a good setting if you have some internal long-running processes, like some cron jobs. 
-  * Enable Abort for All Requests: External application processes will be automatically aborted if the connection is broken, regardless of the source of the request.+  * ''​Enable Abort for All Requests''​: External application processes will be automatically aborted if the connection is broken, regardless of the source of the request.
    
 +If **External Application Abort** is unset, the default setting ''​Enable Abort for All Requests''​ will be applied. To enable no abort, you must explicitly set it to ''​No Abort''​.
  
-If this setting unset, the default setting ''​Enable Abort for All Requests''​ will be applied. To enable no abort, you should set it to ''​No Abort''​.+===== Example Use Case =====
  
-The following is the example ​use case.+An application developer wants to use persistent MySQL connections with PHPLSWS will automatically kill external applications after 30 seconds when the client breaks the connection. This causes MySQL to report the following in the error log:
  
-An application developer wants to use persistent MySQL connections with PHP. LSWS will automatically kill external applications after 30 seconds when the client breaks the connection, which causes MySQL to report in the error log:+  [Warning] Aborted ​connection ​197922 ​to db'​database_table'​ user: '​root'​ host: '​localhost'​ (Got an error reading communication packets)
  
- ​[Warning] Aborted connection 197922 to db: '​database_table'​ user: '​root'​ host: '​localhost'​ (Got an error reading communication packets) +And this appears in the server'​s error log:
- +
-In server'​s error log:+
   [21995] Cmd from child: [extappkill:​22277:​-3:​0]   [21995] Cmd from child: [extappkill:​22277:​-3:​0]
   [22001] sendKillCmdToWatchdog:​ '​extappkill:​22277:​-3:​0'​.   [22001] sendKillCmdToWatchdog:​ '​extappkill:​22277:​-3:​0'​.
  
-It is normal message and harmless for the end user, but for the application developer, ​ killing an idle PHP process after 30 seconds will  kill the MySQL persistent connection and thus the connection ​has to be created again (which ​is relatively expensive). The application developer needs some queries running that need to finish in order to maintain integrity ​no matter ​the PHP process idle or not. For example, if something ​changed ​in DB 1, then DB 2 will have to be changed at the end of the PHP script. In this situation, ​set ''​External Application Abort'' ​to ''​No Abort''​ will solve the issue. +It is normal message and harmless for the end user. But for the application developer, killing an idle PHP process after 30 seconds will also kill the MySQL persistent connectionand thus the connection ​must be created again. This is relatively expensive ​process. The application developer needs some queries running that must finish in order to maintain integrity, whether ​the PHP process ​is idle or not. For example, if something ​changes ​in DB 1, then DB 2 will have to be changed at the end of the PHP script. In this situation, ​setting **External Application Abort** to ''​No Abort''​ will solve the issue.
- +
  
  • Admin
  • Last modified: 2019/06/27 15:35
  • by Lisa Clarke