使用MySQL连接器.NET非常缓慢开启MySQL连接 [英] Very slow opening MySQL connection using MySQL Connector for .net

查看:195
本文介绍了使用MySQL连接器.NET非常缓慢开启MySQL连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打开使用MySQL连接器.NET连接时要解决从MySQL很长的响应时间的问题。

I am trying to solve the problem of very long response times from MySQL when opening a connection using the MySQL Connector for .net.

我已经安装了MySQL 5.5的Azure虚拟机(服务器2008)用--skip-名称解析上运行,而数据库用户帐户主机限制使用的IP地址。我使用for .NET的最新的MySQL Connector在Azure上运行我的WCF服务(在相同的位置US-东,我一直在使用试用订阅,无亲和力集)。在WCF服务我的连接字符串使用托管的MySQL作为服务器参数值虚拟机的内部IP地址。我也有池= TRUE;闵池大小= 2;以防万一(我没有这些参数尝试过)。

I have installed MySQL 5.5 running on an Azure VM (Server 2008) with --skip-name-resolve, and the database user accounts' host restrictions are using IP addresses. I am using the latest MySQL Connector for .net in my WCF service running on Azure (in the same location US- East, I have been using a trial subscription, no affinity set). My connection string in the WCF service is using the internal IP address of the VM hosting MySQL as the server parameter value. I also have "pooling = true;Min Pool Size=2;" just in case (I have tried without these parameters too).

在追查WCF查询响应时间,一旦服务正在运行和处理请求pretty好(即使每个查询的结果是唯一的,因此不会被缓存),我有与MySQL的提供性能没有问题它越来越频繁地撞击。

When tracing the WCF the query response time once the service is running and processing requests are pretty good (even where each query result is unique and so not being cached) and I have no issues with the performance of MySQL providing it's getting hit frequently.

但巨大的问题,我一直无法破解的才获得到数据库的调用后连接到MySQL的开放时间长度已经为约3到4分钟取得 。如果没有数据库调用它需要8个或9秒以上打开连接再次几分钟制成。我裹着实际的conn.open();前后跟踪声明,呼吁,这是我看到的记录一次次闲置几分钟后的行为。

But the huge problem I haven't been able to crack is the length time it takes to get the connection to MySQL Open after no calls to the database have been made for about 3 or 4 minutes. If no database calls are made for a few minutes it takes 8 or 9 seconds or more to open the connection again. I wrapped the actual "conn.open();" with trace statements before and after calling, and this is the behaviour I am seeing logged time and time again after a few minutes of inactivity.

顺便说一句,我也尝试过(现在仍然在用)连接的处理,以确保MySQL的连接器管理连接池的使用的风格。

Incidentally, I have also tried (and still am using) the 'using' style of connection handling to ensure that the MySQL Connector is managing the connection pool.

例如为:
使用(VAR康恩=新的MySqlConnection(Properties.Settings.Default.someConnectionString)){...语句...}

e.g.: using (var conn = new MySqlConnection(Properties.Settings.Default.someConnectionString)) { ... statements ..}

我觉得我已经就这一个死胡同,因此任何建议将不胜AP preciated。

I feel like I have reached a dead end on this one so any suggestions would be greatly appreciated.

推荐答案

我可以解释一下你的问题的才获得到数据库的调用后连接到MySQL打开的时间长度已经进行了约3 4分钟如果没有数据库调用它需要8个或9秒以上,再次打开连接几分钟取得了为什么会发生:

I can explain your question "the length time it takes to get the connection to MySQL Open after no calls to the database have been made for about 3 or 4 minutes. If no database calls are made for a few minutes it takes 8 or 9 seconds or more to open the connection again." why it happens:

在Windows Azure网站上使用热(有源)和冷(无效)的网站中,如果网站没有有效的连接部位的推移它冷态意味着宿主IIS进程退出的概念。当一个新的连接到该网站做它需要几秒钟就可以得到现场准备和工作。当你有相关的对本网站的MySQL的后端,它需要几秒钟更长的时间来请求担任有由IIS宿主进程采取了一些时间来上手。即在活动的响应时间变长,几分钟后的原因。

The Windows Azure websites uses concept of hot (active) and cold (inactive) sites in which if a websites has no active connection the site goes it cold state means the host IIS process exits. When a new connection is made to that websites it takes a few seconds to get the site ready and working. While you have MySQL backend associated to this website, it take a few more seconds longer to get the requested served as there is some time taken by IIS host process to get started. That is the reason after few minutes of in activity the the response time is longer.

您可以看到在Windows Azure上热(有源)和冷(无效)网站的详细信息如下presentation:
http://video.ch9.ms/teched/2012/na/AZR305.pptx

You can see the following presentation for more details on Windows Azure Hot (active) and Cold (inactive) Websites: http://video.ch9.ms/teched/2012/na/AZR305.pptx

由于这个时候,我不知道,不知道你怎么能保持网站总是很热,即使移动到共享网站或这是不可能的。我可以建议你写你的问题的Windows Azure网站已从团队论坛,有人会为您提供一个合适的答案。

As this time, I am not sure and do not know how you can keep the websites always hot, even if moving to shared website or it is not possible at all. What I can suggest you to write your issue to Windows Azure WebSites Forum and someone from that team will provide you an appropriate answer.

这篇关于使用MySQL连接器.NET非常缓慢开启MySQL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆