Announcement

Collapse
No announcement yet.

Help With MindQuake MySQL action plugin: Connection timeouts, and effective use?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help With MindQuake MySQL action plugin: Connection timeouts, and effective use?

    The MindQuake MySQL action plugin (http://www.mindquake.com.br/ - Ulrich) allows connections to MySQL database, yet reveals no information of its time-out when it fails to connect. How long does it take? Is this connection a persistent connection?
    1. On a local machine, the plugin functions exceptionally well for me, yet when I access my MySQL server via local connection in cases where the MySQL server is not available or down, the plugin takes time to give out a success or failed response. And because of that the application is unresponsive for about 3 seconds. How do I solve this?
    2. Since opening a connection with this plugin does not return a database handle but a success or failed response, does this mean this connection will remain open as long as it not closed without timing out when used for some time for other pages of the application or is it advised to keep opening it and closing it every time a connection is required. Articles that I have read so far claims that continuous connecting to any database is something developers should avoid at all cost, as it puts more load on the server. Any thoughts on that?

  • #2
    The MindQuake MySQL action plugin (http://www.mindquake.com.br/ - Ulrich) allows connections to MySQL database, yet reveals no information of its time-out when it fails to connect. How long does it take? Is this connection a persistent connection?
    Yes, it is a persistent connection. The connection to the MySQL server is performed via the mysql_real_connect() function.

    1. On a local machine, the plugin functions exceptionally well for me, yet when I access my MySQL server via local connection in cases where the MySQL server is not available or down, the plugin takes time to give out a success or failed response. And because of that the application is unresponsive for about 3 seconds. How do I solve this?
    Any attempt to establish communication with a remote server is a blocking call. Three seconds sounds perfectly reasonable to me, and you won't be able to reduce this time a lot. When you try to access a web site in your browser, and the server happens to be down, your browser also needs a few seconds before it displays that the page cannot be loaded. The default timeout for operation on network sockets is 20 seconds - you could set a lower timeout if you use my Socket plugin and perform a connection attempt on the MySQL server port (I believe it is 3306). If this connection cannot be completed in the allowed time, then you wouldn't attempt to connect using the MySQL plugin.

    2. Since opening a connection with this plugin does not return a database handle but a success or failed response, does this mean this connection will remain open as long as it not closed without timing out when used for some time for other pages of the application or is it advised to keep opening it and closing it every time a connection is required. Articles that I have read so far claims that continuous connecting to any database is something developers should avoid at all cost, as it puts more load on the server. Any thoughts on that?
    Actually, the plugin manages the MySQL handle (socket) internally. Once a connection was established, the database handle is used in all subsequent operations - there is just no need to repeat this handle in the Lua script. The handle will be used for all operations until the connection is severed. If you expect that there are long intervals between operations on the database, you could use MySQL.Ping() in a timer to keep the connection alive.

    Ulrich

    Comment


    • #3
      Thank you Ulrich. This is an awesome response.

      Comment

      Working...
      X