What value of thread_cache_size should I use?What limits the maximum number of connections on a Linux server?How to adjust MySQL performancemysql always using maximum connectionMySQL InnoDB database 'hangs'MySQL too many connections during normal conditions (Percona, InnoDB)ubuntu mysql too many connectionsHigh server load after upgrading to MySql5.5FreeBSD Established Connections Maxing out at 300MySQL Semi synchronous replication stuck

Emotional immaturity of comic-book version of superhero Shazam

Where are the "shires" in the UK?

Refinish or replace an old staircase

How should I tell my manager I'm not paying for an optional after work event I'm not going to?

3D Volume in TIKZ

How can I get people to remember my character's gender?

What are the differences between credential stuffing and password spraying?

In Russian, how do you idiomatically express the idea of the figurative "overnight"?

How did the Venus Express detect lightning?

Where in Bitcoin Core does it do X?

How to use dependency injection and avoid temporal coupling?

How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?

My advisor talks about me to his colleague

How can I get a job without pushing my family's income into a higher tax bracket?

Pressure inside an infinite ocean?

Gerrymandering Puzzle - Rig the Election

Find the cheapest shipping option based on item weight

How can I support myself financially as a 17 year old with a loan?

Out of scope work duties and resignation

Are there any of the Children of the Forest left, or are they extinct?

How to write a 12-bar blues melody

PWM 1Hz on solid state relay

Why wasn't the Night King naked in S08E03?

How to safely wipe a USB flash drive



What value of thread_cache_size should I use?


What limits the maximum number of connections on a Linux server?How to adjust MySQL performancemysql always using maximum connectionMySQL InnoDB database 'hangs'MySQL too many connections during normal conditions (Percona, InnoDB)ubuntu mysql too many connectionsHigh server load after upgrading to MySql5.5FreeBSD Established Connections Maxing out at 300MySQL Semi synchronous replication stuck






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








24















I'm using Asp.Net together with MySQL. In the .Net connection string, I have set Max Pool Size to 150.



If I run the following I get these values:



SHOW GLOBAL STATUS LIKE 'max_used_connections'; gives 66
SHOW GLOBAL STATUS LIKE 'Threads_created'; gives 66
SHOW GLOBAL STATUS LIKE 'connections'; gives 474


Which gives Threads_created / Connections = 0,1392.



So from that it seems like I need to increase thread_cache_size.



But if I run SHOW PROCESSLIST I always see that I have a lot of connections open (most of them sleeping) because of the pool created by .Net. Do I still need to set the thread_cache_size as I still will reuse the connections from the connection pool? If the Pool Size is 150 do you think a good value would be to set thread_cache_size to 150+? Would this affect CPU and memory a lot?










share|improve this question






























    24















    I'm using Asp.Net together with MySQL. In the .Net connection string, I have set Max Pool Size to 150.



    If I run the following I get these values:



    SHOW GLOBAL STATUS LIKE 'max_used_connections'; gives 66
    SHOW GLOBAL STATUS LIKE 'Threads_created'; gives 66
    SHOW GLOBAL STATUS LIKE 'connections'; gives 474


    Which gives Threads_created / Connections = 0,1392.



    So from that it seems like I need to increase thread_cache_size.



    But if I run SHOW PROCESSLIST I always see that I have a lot of connections open (most of them sleeping) because of the pool created by .Net. Do I still need to set the thread_cache_size as I still will reuse the connections from the connection pool? If the Pool Size is 150 do you think a good value would be to set thread_cache_size to 150+? Would this affect CPU and memory a lot?










    share|improve this question


























      24












      24








      24


      18






      I'm using Asp.Net together with MySQL. In the .Net connection string, I have set Max Pool Size to 150.



      If I run the following I get these values:



      SHOW GLOBAL STATUS LIKE 'max_used_connections'; gives 66
      SHOW GLOBAL STATUS LIKE 'Threads_created'; gives 66
      SHOW GLOBAL STATUS LIKE 'connections'; gives 474


      Which gives Threads_created / Connections = 0,1392.



      So from that it seems like I need to increase thread_cache_size.



      But if I run SHOW PROCESSLIST I always see that I have a lot of connections open (most of them sleeping) because of the pool created by .Net. Do I still need to set the thread_cache_size as I still will reuse the connections from the connection pool? If the Pool Size is 150 do you think a good value would be to set thread_cache_size to 150+? Would this affect CPU and memory a lot?










      share|improve this question
















      I'm using Asp.Net together with MySQL. In the .Net connection string, I have set Max Pool Size to 150.



      If I run the following I get these values:



      SHOW GLOBAL STATUS LIKE 'max_used_connections'; gives 66
      SHOW GLOBAL STATUS LIKE 'Threads_created'; gives 66
      SHOW GLOBAL STATUS LIKE 'connections'; gives 474


      Which gives Threads_created / Connections = 0,1392.



      So from that it seems like I need to increase thread_cache_size.



      But if I run SHOW PROCESSLIST I always see that I have a lot of connections open (most of them sleeping) because of the pool created by .Net. Do I still need to set the thread_cache_size as I still will reuse the connections from the connection pool? If the Pool Size is 150 do you think a good value would be to set thread_cache_size to 150+? Would this affect CPU and memory a lot?







      mysql .net connections tuning






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 21 '17 at 9:30









      7ochem

      2761312




      2761312










      asked Jul 18 '12 at 13:37









      MartinMartin

      2141211




      2141211




















          3 Answers
          3






          active

          oldest

          votes


















          42














          Based on the info in the MySQL Documentation you should do the following: Find out what the highest number of simultaneous connections mysqld has had using Connections, Threads_created, and Max_used_connections,



          • SHOW GLOBAL STATUS LIKE 'Connections';

          • SHOW GLOBAL STATUS LIKE 'Threads_created';

          • SHOW GLOBAL STATUS LIKE 'Max_used_connections';

          Try calculating the following



          Threads_created / Connections : If this is over 0.01, then increase thread_cache_size. At the very least, thread_cache_size should be greater than Max_used_connections.






          share|improve this answer

























          • Thanks for great comment! I updated my question a little bit.

            – Martin
            Jul 19 '12 at 6:59











          • I think you were intending mysql> SHOW GLOBAL STATUS LIKE 'connections'; (you have written max_used_connections twice)

            – Alekc
            Oct 11 '12 at 7:15







          • 1





            I just want to add that by referring to this dev.mysql.com/doc/refman/5.7/en/… you should add 8 to Max_used_connections for the thread_cache_size value (without exceeding 100)

            – CME64
            Nov 23 '16 at 11:37






          • 1





            Actually, the manual suggests a default of (1% of the mac_used_connections) + 8 .... or 100...whichever is less.

            – Christopher McGowan
            Apr 20 '17 at 22:36











          • For me the #'s are 264/103134 which works out to 0.0026 which is way less than 0.01 But my MaxUsedConnections is 72, so the last sentence is terribly conflicted

            – boatcoder
            Nov 1 '17 at 18:57


















          10














          According to the MySQL docs, you should set thread_cache_size so that most new connections use threads from the cache rather than newly created threads. This saves some thread-creation overhead, though normally does not create a significant performance improvement:




          Requests for threads are satisfied by reusing threads taken from the
          cache if possible, and only when the cache is empty is a new thread
          created. This variable can be increased to improve performance if you
          have a lot of new connections. Normally, this does not provide a
          notable performance improvement
          if you have a good thread
          implementation. However, if your server sees hundreds of connections
          per second you should normally set thread_cache_size high enough so
          that most new connections use cached threads. (source)




          This would mean that you should set your thread_cache_size so that Threads_created / Connections (the % of connections that lead to the creation of new threads) is rather low. If you take the MySQL docs literally ("most"), the value should be < 50%. RolandoMySQLDBA's answer says < 1%. I don't know who's closer to the truth.



          You should not set thread_cache_size higher than Max_used_connections. The final sentence in RolandoMySQLDBA's answer ("At the very least, thread_cache_size should be greater than Max_used_connections") doesn't seem sensible because it says that you should keep more threads in the cache than your server ever uses. MySQL will never put that many threads in the cache anyway -- it does not pre-emptively put threads in the cache -- it only puts them there after a client creates a thread and disconnects. If you never have X clients connecting at the same time, you will never have X threads in the cache:




          When a client disconnects, the client's threads are put in the cache
          if there are fewer than thread_cache_size threads there. (source)




          See also this answer by Michael:




          Setting thread_cache_size to a value larger than max_connections seems
          like tremendously unhelpful advice... the cache can't possibly grow
          larger than max_connections and even a cache anywhere close to that
          size could only make sense if you have a tremendous amount of churn on
          your threads... which, in a well-behaved application, won't be the
          case.




          https://dba.stackexchange.com/a/28701






          share|improve this answer

























          • i think so! after i test this config, "thread_cache_size should be greater than Max_used_connections" not helpfull.

            – CK.Nguyen
            Aug 11 '16 at 12:47


















          -2














          In the common working day, would a 'new hire' possibly need a connection?
          Most magicians will not know how many people could be hired in the next few days.
          V 8 of MySQL suggests CAP thread_cache_size at 100 to prevent overload regardless of max_used_connections.
          For me, 100 is a good CAP.



          See this link, please.



          https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_thread_cache_size





          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "2"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f408845%2fwhat-value-of-thread-cache-size-should-i-use%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            42














            Based on the info in the MySQL Documentation you should do the following: Find out what the highest number of simultaneous connections mysqld has had using Connections, Threads_created, and Max_used_connections,



            • SHOW GLOBAL STATUS LIKE 'Connections';

            • SHOW GLOBAL STATUS LIKE 'Threads_created';

            • SHOW GLOBAL STATUS LIKE 'Max_used_connections';

            Try calculating the following



            Threads_created / Connections : If this is over 0.01, then increase thread_cache_size. At the very least, thread_cache_size should be greater than Max_used_connections.






            share|improve this answer

























            • Thanks for great comment! I updated my question a little bit.

              – Martin
              Jul 19 '12 at 6:59











            • I think you were intending mysql> SHOW GLOBAL STATUS LIKE 'connections'; (you have written max_used_connections twice)

              – Alekc
              Oct 11 '12 at 7:15







            • 1





              I just want to add that by referring to this dev.mysql.com/doc/refman/5.7/en/… you should add 8 to Max_used_connections for the thread_cache_size value (without exceeding 100)

              – CME64
              Nov 23 '16 at 11:37






            • 1





              Actually, the manual suggests a default of (1% of the mac_used_connections) + 8 .... or 100...whichever is less.

              – Christopher McGowan
              Apr 20 '17 at 22:36











            • For me the #'s are 264/103134 which works out to 0.0026 which is way less than 0.01 But my MaxUsedConnections is 72, so the last sentence is terribly conflicted

              – boatcoder
              Nov 1 '17 at 18:57















            42














            Based on the info in the MySQL Documentation you should do the following: Find out what the highest number of simultaneous connections mysqld has had using Connections, Threads_created, and Max_used_connections,



            • SHOW GLOBAL STATUS LIKE 'Connections';

            • SHOW GLOBAL STATUS LIKE 'Threads_created';

            • SHOW GLOBAL STATUS LIKE 'Max_used_connections';

            Try calculating the following



            Threads_created / Connections : If this is over 0.01, then increase thread_cache_size. At the very least, thread_cache_size should be greater than Max_used_connections.






            share|improve this answer

























            • Thanks for great comment! I updated my question a little bit.

              – Martin
              Jul 19 '12 at 6:59











            • I think you were intending mysql> SHOW GLOBAL STATUS LIKE 'connections'; (you have written max_used_connections twice)

              – Alekc
              Oct 11 '12 at 7:15







            • 1





              I just want to add that by referring to this dev.mysql.com/doc/refman/5.7/en/… you should add 8 to Max_used_connections for the thread_cache_size value (without exceeding 100)

              – CME64
              Nov 23 '16 at 11:37






            • 1





              Actually, the manual suggests a default of (1% of the mac_used_connections) + 8 .... or 100...whichever is less.

              – Christopher McGowan
              Apr 20 '17 at 22:36











            • For me the #'s are 264/103134 which works out to 0.0026 which is way less than 0.01 But my MaxUsedConnections is 72, so the last sentence is terribly conflicted

              – boatcoder
              Nov 1 '17 at 18:57













            42












            42








            42







            Based on the info in the MySQL Documentation you should do the following: Find out what the highest number of simultaneous connections mysqld has had using Connections, Threads_created, and Max_used_connections,



            • SHOW GLOBAL STATUS LIKE 'Connections';

            • SHOW GLOBAL STATUS LIKE 'Threads_created';

            • SHOW GLOBAL STATUS LIKE 'Max_used_connections';

            Try calculating the following



            Threads_created / Connections : If this is over 0.01, then increase thread_cache_size. At the very least, thread_cache_size should be greater than Max_used_connections.






            share|improve this answer















            Based on the info in the MySQL Documentation you should do the following: Find out what the highest number of simultaneous connections mysqld has had using Connections, Threads_created, and Max_used_connections,



            • SHOW GLOBAL STATUS LIKE 'Connections';

            • SHOW GLOBAL STATUS LIKE 'Threads_created';

            • SHOW GLOBAL STATUS LIKE 'Max_used_connections';

            Try calculating the following



            Threads_created / Connections : If this is over 0.01, then increase thread_cache_size. At the very least, thread_cache_size should be greater than Max_used_connections.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Oct 11 '12 at 7:16

























            answered Jul 18 '12 at 18:08









            RolandoMySQLDBARolandoMySQLDBA

            14.8k33868




            14.8k33868












            • Thanks for great comment! I updated my question a little bit.

              – Martin
              Jul 19 '12 at 6:59











            • I think you were intending mysql> SHOW GLOBAL STATUS LIKE 'connections'; (you have written max_used_connections twice)

              – Alekc
              Oct 11 '12 at 7:15







            • 1





              I just want to add that by referring to this dev.mysql.com/doc/refman/5.7/en/… you should add 8 to Max_used_connections for the thread_cache_size value (without exceeding 100)

              – CME64
              Nov 23 '16 at 11:37






            • 1





              Actually, the manual suggests a default of (1% of the mac_used_connections) + 8 .... or 100...whichever is less.

              – Christopher McGowan
              Apr 20 '17 at 22:36











            • For me the #'s are 264/103134 which works out to 0.0026 which is way less than 0.01 But my MaxUsedConnections is 72, so the last sentence is terribly conflicted

              – boatcoder
              Nov 1 '17 at 18:57

















            • Thanks for great comment! I updated my question a little bit.

              – Martin
              Jul 19 '12 at 6:59











            • I think you were intending mysql> SHOW GLOBAL STATUS LIKE 'connections'; (you have written max_used_connections twice)

              – Alekc
              Oct 11 '12 at 7:15







            • 1





              I just want to add that by referring to this dev.mysql.com/doc/refman/5.7/en/… you should add 8 to Max_used_connections for the thread_cache_size value (without exceeding 100)

              – CME64
              Nov 23 '16 at 11:37






            • 1





              Actually, the manual suggests a default of (1% of the mac_used_connections) + 8 .... or 100...whichever is less.

              – Christopher McGowan
              Apr 20 '17 at 22:36











            • For me the #'s are 264/103134 which works out to 0.0026 which is way less than 0.01 But my MaxUsedConnections is 72, so the last sentence is terribly conflicted

              – boatcoder
              Nov 1 '17 at 18:57
















            Thanks for great comment! I updated my question a little bit.

            – Martin
            Jul 19 '12 at 6:59





            Thanks for great comment! I updated my question a little bit.

            – Martin
            Jul 19 '12 at 6:59













            I think you were intending mysql> SHOW GLOBAL STATUS LIKE 'connections'; (you have written max_used_connections twice)

            – Alekc
            Oct 11 '12 at 7:15






            I think you were intending mysql> SHOW GLOBAL STATUS LIKE 'connections'; (you have written max_used_connections twice)

            – Alekc
            Oct 11 '12 at 7:15





            1




            1





            I just want to add that by referring to this dev.mysql.com/doc/refman/5.7/en/… you should add 8 to Max_used_connections for the thread_cache_size value (without exceeding 100)

            – CME64
            Nov 23 '16 at 11:37





            I just want to add that by referring to this dev.mysql.com/doc/refman/5.7/en/… you should add 8 to Max_used_connections for the thread_cache_size value (without exceeding 100)

            – CME64
            Nov 23 '16 at 11:37




            1




            1





            Actually, the manual suggests a default of (1% of the mac_used_connections) + 8 .... or 100...whichever is less.

            – Christopher McGowan
            Apr 20 '17 at 22:36





            Actually, the manual suggests a default of (1% of the mac_used_connections) + 8 .... or 100...whichever is less.

            – Christopher McGowan
            Apr 20 '17 at 22:36













            For me the #'s are 264/103134 which works out to 0.0026 which is way less than 0.01 But my MaxUsedConnections is 72, so the last sentence is terribly conflicted

            – boatcoder
            Nov 1 '17 at 18:57





            For me the #'s are 264/103134 which works out to 0.0026 which is way less than 0.01 But my MaxUsedConnections is 72, so the last sentence is terribly conflicted

            – boatcoder
            Nov 1 '17 at 18:57













            10














            According to the MySQL docs, you should set thread_cache_size so that most new connections use threads from the cache rather than newly created threads. This saves some thread-creation overhead, though normally does not create a significant performance improvement:




            Requests for threads are satisfied by reusing threads taken from the
            cache if possible, and only when the cache is empty is a new thread
            created. This variable can be increased to improve performance if you
            have a lot of new connections. Normally, this does not provide a
            notable performance improvement
            if you have a good thread
            implementation. However, if your server sees hundreds of connections
            per second you should normally set thread_cache_size high enough so
            that most new connections use cached threads. (source)




            This would mean that you should set your thread_cache_size so that Threads_created / Connections (the % of connections that lead to the creation of new threads) is rather low. If you take the MySQL docs literally ("most"), the value should be < 50%. RolandoMySQLDBA's answer says < 1%. I don't know who's closer to the truth.



            You should not set thread_cache_size higher than Max_used_connections. The final sentence in RolandoMySQLDBA's answer ("At the very least, thread_cache_size should be greater than Max_used_connections") doesn't seem sensible because it says that you should keep more threads in the cache than your server ever uses. MySQL will never put that many threads in the cache anyway -- it does not pre-emptively put threads in the cache -- it only puts them there after a client creates a thread and disconnects. If you never have X clients connecting at the same time, you will never have X threads in the cache:




            When a client disconnects, the client's threads are put in the cache
            if there are fewer than thread_cache_size threads there. (source)




            See also this answer by Michael:




            Setting thread_cache_size to a value larger than max_connections seems
            like tremendously unhelpful advice... the cache can't possibly grow
            larger than max_connections and even a cache anywhere close to that
            size could only make sense if you have a tremendous amount of churn on
            your threads... which, in a well-behaved application, won't be the
            case.




            https://dba.stackexchange.com/a/28701






            share|improve this answer

























            • i think so! after i test this config, "thread_cache_size should be greater than Max_used_connections" not helpfull.

              – CK.Nguyen
              Aug 11 '16 at 12:47















            10














            According to the MySQL docs, you should set thread_cache_size so that most new connections use threads from the cache rather than newly created threads. This saves some thread-creation overhead, though normally does not create a significant performance improvement:




            Requests for threads are satisfied by reusing threads taken from the
            cache if possible, and only when the cache is empty is a new thread
            created. This variable can be increased to improve performance if you
            have a lot of new connections. Normally, this does not provide a
            notable performance improvement
            if you have a good thread
            implementation. However, if your server sees hundreds of connections
            per second you should normally set thread_cache_size high enough so
            that most new connections use cached threads. (source)




            This would mean that you should set your thread_cache_size so that Threads_created / Connections (the % of connections that lead to the creation of new threads) is rather low. If you take the MySQL docs literally ("most"), the value should be < 50%. RolandoMySQLDBA's answer says < 1%. I don't know who's closer to the truth.



            You should not set thread_cache_size higher than Max_used_connections. The final sentence in RolandoMySQLDBA's answer ("At the very least, thread_cache_size should be greater than Max_used_connections") doesn't seem sensible because it says that you should keep more threads in the cache than your server ever uses. MySQL will never put that many threads in the cache anyway -- it does not pre-emptively put threads in the cache -- it only puts them there after a client creates a thread and disconnects. If you never have X clients connecting at the same time, you will never have X threads in the cache:




            When a client disconnects, the client's threads are put in the cache
            if there are fewer than thread_cache_size threads there. (source)




            See also this answer by Michael:




            Setting thread_cache_size to a value larger than max_connections seems
            like tremendously unhelpful advice... the cache can't possibly grow
            larger than max_connections and even a cache anywhere close to that
            size could only make sense if you have a tremendous amount of churn on
            your threads... which, in a well-behaved application, won't be the
            case.




            https://dba.stackexchange.com/a/28701






            share|improve this answer

























            • i think so! after i test this config, "thread_cache_size should be greater than Max_used_connections" not helpfull.

              – CK.Nguyen
              Aug 11 '16 at 12:47













            10












            10








            10







            According to the MySQL docs, you should set thread_cache_size so that most new connections use threads from the cache rather than newly created threads. This saves some thread-creation overhead, though normally does not create a significant performance improvement:




            Requests for threads are satisfied by reusing threads taken from the
            cache if possible, and only when the cache is empty is a new thread
            created. This variable can be increased to improve performance if you
            have a lot of new connections. Normally, this does not provide a
            notable performance improvement
            if you have a good thread
            implementation. However, if your server sees hundreds of connections
            per second you should normally set thread_cache_size high enough so
            that most new connections use cached threads. (source)




            This would mean that you should set your thread_cache_size so that Threads_created / Connections (the % of connections that lead to the creation of new threads) is rather low. If you take the MySQL docs literally ("most"), the value should be < 50%. RolandoMySQLDBA's answer says < 1%. I don't know who's closer to the truth.



            You should not set thread_cache_size higher than Max_used_connections. The final sentence in RolandoMySQLDBA's answer ("At the very least, thread_cache_size should be greater than Max_used_connections") doesn't seem sensible because it says that you should keep more threads in the cache than your server ever uses. MySQL will never put that many threads in the cache anyway -- it does not pre-emptively put threads in the cache -- it only puts them there after a client creates a thread and disconnects. If you never have X clients connecting at the same time, you will never have X threads in the cache:




            When a client disconnects, the client's threads are put in the cache
            if there are fewer than thread_cache_size threads there. (source)




            See also this answer by Michael:




            Setting thread_cache_size to a value larger than max_connections seems
            like tremendously unhelpful advice... the cache can't possibly grow
            larger than max_connections and even a cache anywhere close to that
            size could only make sense if you have a tremendous amount of churn on
            your threads... which, in a well-behaved application, won't be the
            case.




            https://dba.stackexchange.com/a/28701






            share|improve this answer















            According to the MySQL docs, you should set thread_cache_size so that most new connections use threads from the cache rather than newly created threads. This saves some thread-creation overhead, though normally does not create a significant performance improvement:




            Requests for threads are satisfied by reusing threads taken from the
            cache if possible, and only when the cache is empty is a new thread
            created. This variable can be increased to improve performance if you
            have a lot of new connections. Normally, this does not provide a
            notable performance improvement
            if you have a good thread
            implementation. However, if your server sees hundreds of connections
            per second you should normally set thread_cache_size high enough so
            that most new connections use cached threads. (source)




            This would mean that you should set your thread_cache_size so that Threads_created / Connections (the % of connections that lead to the creation of new threads) is rather low. If you take the MySQL docs literally ("most"), the value should be < 50%. RolandoMySQLDBA's answer says < 1%. I don't know who's closer to the truth.



            You should not set thread_cache_size higher than Max_used_connections. The final sentence in RolandoMySQLDBA's answer ("At the very least, thread_cache_size should be greater than Max_used_connections") doesn't seem sensible because it says that you should keep more threads in the cache than your server ever uses. MySQL will never put that many threads in the cache anyway -- it does not pre-emptively put threads in the cache -- it only puts them there after a client creates a thread and disconnects. If you never have X clients connecting at the same time, you will never have X threads in the cache:




            When a client disconnects, the client's threads are put in the cache
            if there are fewer than thread_cache_size threads there. (source)




            See also this answer by Michael:




            Setting thread_cache_size to a value larger than max_connections seems
            like tremendously unhelpful advice... the cache can't possibly grow
            larger than max_connections and even a cache anywhere close to that
            size could only make sense if you have a tremendous amount of churn on
            your threads... which, in a well-behaved application, won't be the
            case.




            https://dba.stackexchange.com/a/28701







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 25 at 4:03









            Pang

            15716




            15716










            answered Oct 16 '15 at 6:42









            Tomasz P. SzynalskiTomasz P. Szynalski

            10115




            10115












            • i think so! after i test this config, "thread_cache_size should be greater than Max_used_connections" not helpfull.

              – CK.Nguyen
              Aug 11 '16 at 12:47

















            • i think so! after i test this config, "thread_cache_size should be greater than Max_used_connections" not helpfull.

              – CK.Nguyen
              Aug 11 '16 at 12:47
















            i think so! after i test this config, "thread_cache_size should be greater than Max_used_connections" not helpfull.

            – CK.Nguyen
            Aug 11 '16 at 12:47





            i think so! after i test this config, "thread_cache_size should be greater than Max_used_connections" not helpfull.

            – CK.Nguyen
            Aug 11 '16 at 12:47











            -2














            In the common working day, would a 'new hire' possibly need a connection?
            Most magicians will not know how many people could be hired in the next few days.
            V 8 of MySQL suggests CAP thread_cache_size at 100 to prevent overload regardless of max_used_connections.
            For me, 100 is a good CAP.



            See this link, please.



            https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_thread_cache_size





            share|improve this answer





























              -2














              In the common working day, would a 'new hire' possibly need a connection?
              Most magicians will not know how many people could be hired in the next few days.
              V 8 of MySQL suggests CAP thread_cache_size at 100 to prevent overload regardless of max_used_connections.
              For me, 100 is a good CAP.



              See this link, please.



              https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_thread_cache_size





              share|improve this answer



























                -2












                -2








                -2







                In the common working day, would a 'new hire' possibly need a connection?
                Most magicians will not know how many people could be hired in the next few days.
                V 8 of MySQL suggests CAP thread_cache_size at 100 to prevent overload regardless of max_used_connections.
                For me, 100 is a good CAP.



                See this link, please.



                https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_thread_cache_size





                share|improve this answer















                In the common working day, would a 'new hire' possibly need a connection?
                Most magicians will not know how many people could be hired in the next few days.
                V 8 of MySQL suggests CAP thread_cache_size at 100 to prevent overload regardless of max_used_connections.
                For me, 100 is a good CAP.



                See this link, please.



                https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_thread_cache_size






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 5 '18 at 10:29

























                answered Oct 9 '17 at 18:37









                Wilson HauckWilson Hauck

                34718




                34718



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Server Fault!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f408845%2fwhat-value-of-thread-cache-size-should-i-use%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                    Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                    Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020