title: Strange connection error occures when executing multiple queries by multiple threads - Google Cloud SQL
body: <p>after some test rounds, i saw that google cloud sql is not fast as required, my main problem is when i execute many queries one by one, not at once , it takes very longer time compared with executing them by multiple threads.</p>
  
  <p>so, i decided to execute many queries at the same time by threading, i am using this code to load some datatables :</p>
  
  <pre><code>    Dim T As New Threading.Thread(AddressOf loadPlacesData)
      Dim T2 As New Threading.Thread(AddressOf loadPortsData)
      Dim T3 As New Threading.Thread(AddressOf loadAgentsData)
      Dim T4 As New Threading.Thread(AddressOf loadAirlinesData)
      Dim T5 As New Threading.Thread(AddressOf loadCountriesData)
      Dim T6 As New Threading.Thread(AddressOf loadTransportCompaniesData)
      Dim T7 As New Threading.Thread(AddressOf loadHallsData)
      Dim T8 As New Threading.Thread(AddressOf loadUsersData)
      T.Start()
      T2.Start()
      T3.Start()
      T4.Start()
      T5.Start()
      T6.Start()
      T7.Start()
      T8.Start()
  </code></pre>
  
  <p>and the load methods contains code like this :</p>
  
  <pre><code>    Public Sub loadUsersData()
      Try
          Dim command As New MySqlCommand
          command.CommandType = CommandType.Text
          Dim Conn As New MySqlConnection(ConnectionString)
          command.CommandText = "Select UserID from Users"
          command.Connection = Conn
          Dim d As New MySqlDataAdapter(command)
          d.Fill(usersData)
          Conn.Dispose() : Command.Dispose()
          completed += 1
      Catch ex As MySqlException
          MsgBox(ex.Message, MsgBoxStyle.Exclamation)
      End Try
  End Sub
  </code></pre>
  
  <p>it is working very well and fast sometimes, and sometimes it doesn't load any thing and throws this exception :</p>
  
  <pre><code>Unable to connect to any of the specified MySQL hosts.
  </code></pre>
  
  <p>what is the problem ?! it is thrown randomly</p>
  
  <p>1- i can connect and do any query by Workbench without any problem.</p>
  
  <p>2- if i do not use threads, it works well.</p>
  
  <p>notes :</p>
  
  <p>connection string : <code>"Server=XX.XX.XX.XX;port=3306;Database=mydatabase;uid=root;password=mypass;SSlMode=Required;CertificateFile=C:\client-cert.pfx;certificatepassword='';pooling=true"</code></p>
  
  <p>.Net 4.0
  MySqlConnector 6.8.3</p>
  
  <p>visual studio 2012</p>
  
  <p>Google Cloud Sql : D1 – 512M RAM</p>
  
  <p>Thanks.</p>