Is there any use for wrapping CFTHREAD around database inserts?

We have several thousand directories with pages that are accessed up to half a million times every day. At the end of each page hit, we insert some of the CGI variables into the database. If the form was submitted or a search was performed, we insert some of this information into another database. No information should be returned from each of these database inserts. These inserts occur at the end of page processing.

I read that after the start-up stream starts, page processing continues and does not wait for an answer. It seems that this will speed up the page because it does not wait for requests on the pages that will be launched. Is it correct?

Is there any use for inserting these database inserts into my own thread?

<cffunction
    name="OnRequest"
    access="public"
    returntype="void"
    output="true"
    hint="Fires after pre page processing is complete.">

    <cfargument name="RequestedContent" type="string" required="true" />


    <!--- OUTPUT THE PAGE CONTENT --->
    <cfinclude template="#ARGUMENTS.RequestedContent#" />

    <cfscript>
        thread
            action="run"
            name="Tracking" {
            include "track1.cfm";
            include "track2.cfm";
        }
    </cfscript>

    <cfreturn />
</cffunction>
+4
source share
3 answers

I would say: "No, there is little use in this." You would save your user a few more ms, but you would put your ColdFusion server twice the load, which, in turn, could lead to a performance hit in all directions. The server has only a finite number of threads available for use for all requests, so doubling the number you use for each request doubles the risk of using "em all up".

, , , , .

, , , , ( ).

: , .

+2

, , . , , http- .

, , , , , .

+3

, . . , , , , .

In this case, you can think about the order of attachments in the application for a minute or two, and then perform bulk insertion in the stream. This obviously has some risk of data loss if the server crashes before clearing the queue, and this will require a bit more work to ensure thread safety. However, if you do not need the inserted data immediately, it may work well.

+2
source

Source: https://habr.com/ru/post/1547937/


All Articles