I have been exploring MySQL JDBC driver and understand that it is able to do load balancing with this url ("jdbc:mysql:loadbalance://").

我一直在探索MySQL JDBC驱动程序,并理解它能够使用这个url(“JDBC: MySQL:loadbalance://”)进行负载平衡。

I looked into the documentation and it seems that only random and best response time methods are used for load balancing (link: http://dev.mysql.com/doc/refman/5.0/es/connector-j-reference-configuration-properties.html syntax is loadBalanceStrategy).

我查看了文档,似乎只有随机和最佳的响应时间方法用于负载平衡(link: http://dev.mysql.com/doc/refman/5.0/es/connector-j-reference-configuration-properties.html语法是loadBalanceStrategy)。

Questions

问题

  1. Is there a way to configure roundrobin as the load balancing strategy for the JDBC driver? I understand that other load balancing methods may be better but I am trying to use the round-robin method for my experiments.
  2. 是否有一种方法可以将roundrobin配置为JDBC驱动程序的负载平衡策略?我知道其他的负载平衡方法可能更好,但是我正在尝试使用循环方法进行我的实验。
  3. Is it a good idea to implement load balancing (I am open to whichever load balancing strategy) for MySQL ndb cluster (Multimaster with synchronous replication)? By the way, I have only 2 machines acting as masters and both are able to receive writes and reads. Although MySQL mentioned the use of the JDBC driver with ndb cluster (refer to quote 1 below), I was wondering if using load balancing for a multimaster ndb cluster would actually worsen the performance (refer to quote 2)?
  4. 对于MySQL ndb集群(具有同步复制的Multimaster),实现负载平衡(我对任何负载平衡策略都是开放的)是一个好主意吗?顺便说一下,我只有2台机器作为主人,他们都能收到写和读。尽管MySQL提到了使用ndb集群的JDBC驱动程序(请参阅下面的引用1),但是我想知道,使用负载均衡来实现多主ndb集群是否会使性能变得更糟(参见引用2)?
  1. Quoted from https://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-basics.html - "MySQL clients using a MySQL Cluster as a data source can be modified to take advantage of the ability to connect with multiple MySQL servers to achieve load balancing and failover. For example, Java clients using Connector/J 5.0.6 and later can use jdbc:mysql:loadbalance:// URLs (improved in Connector/J 5.1.7) to achieve load balancing transparently; for more information about using Connector/J with MySQL Cluster, see Using Connector/J with MySQL Cluster."

    使用MySQL集群作为数据源的MySQL客户端可以被修改,以利用与多个MySQL服务器连接的能力来实现负载平衡和故障转移。例如,使用连接器/ j5.0.6和之后的Java客户端可以使用jdbc:mysql:loadbalance:// url(在连接器/ j5.1.7中改进)以透明地实现负载平衡;有关在MySQL集群中使用连接器/J的更多信息,请参见使用连接器/J和MySQL集群。

  2. Quoted from https://dba.stackexchange.com/questions/11789/load-balanced-mysql-cluster-without-load-balancer - "replication delay on production servers might be up to a full second - I have tested this in a remote colocation and in our datacenter and for like 99% of the time it's 0, but sometimes mysql shows 1s. On massive traffic I had many collisions due to client application making two requests resulting in two queries, insert and select. For some cases, the row just wasn't there yet, so We used hash of the userID and it fixed the problem"

    从https://dba.stackexchange.com/questions/11789/load-balanced-mysql-cluster- withoutload-balancer—“生产服务器的复制延迟可能会达到一个完整的秒——我已经在远程托管和数据中心测试了这一点,在99%的时间里,它是0,但有时mysql显示1。在大量的通信中,由于客户端应用程序产生两个请求,导致两个查询、插入和选择,导致了许多冲突。在某些情况下,行还没有出现,所以我们使用了userID的散列,它解决了问题"

In response to Howard's reply, these are some of the things I have done prior to posting this question - I have tried to use roundRobinLoadBalance as part of the JDBC connection string (URL) but an error occurred stating that it was not supported. A search on the internet also shows that other people also face problem with trying to use roundRobinLoadBalance. Hence I was trying to see if there is another way to do it.

为了响应Howard的回复,这些是我在发布这个问题之前所做的一些事情——我尝试使用roundRobinLoadBalance作为JDBC连接字符串(URL)的一部分,但是出现了一个错误,说明它不受支持。在互联网上的搜索也显示,其他人也面临着使用roundRobinLoadBalance的问题。所以我想看看有没有别的办法。

1 个解决方案

#1


1

Q1) Is there a way to configure roundrobin as the load balancing strategy?

是否有一种方法可以将roundrobin配置为负载平衡策略?

Round-roubin's load balancing algorithm gives each server an equal load. When all servers' performances are the same then it makes sense to use it.

圆周率的负载均衡算法使每个服务器负载相等。当所有服务器的性能都相同的时候,使用它是有意义的。

Weighted round-robin on the other hand allows load balancing configuration for each server. This makes sense when you have servers with different performances.

另一方面,加权循环允许为每个服务器配置负载平衡配置。当有不同性能的服务器时,这是有意义的。

For example for Glassfish read: Weighted Round Robin

例如,对Glassfish的阅读:加权循环。

Q2) Is it a good idea to implement load balancing (I am open to whichever load balancing strategy) for MySQL ndb cluster (Multimaster with synchronous replication)? By the way, I have only 2 machines acting as masters and both are able to receive writes and reads. Although MySQL mentioned the use of the JDBC driver with ndb cluster (refer to quote 1 below), I was wondering if using load balancing for a multimaster ndb cluster would actually worsen the performance (refer to quote 2)?

对于MySQL ndb集群(具有同步复制的Multimaster),实现负载平衡(我对任何负载平衡策略都是开放的)是一个好主意吗?顺便说一下,我只有2台机器作为主人,他们都能收到写和读。尽管MySQL提到了使用ndb集群的JDBC驱动程序(请参阅下面的引用1),但是我想知道,使用负载均衡来实现多主ndb集群是否会使性能变得更糟(参见引用2)?

If the two servers are identical in performance, there is no need to configure the load balancing. It will distrbute the load to each node equally.

如果两个服务器在性能上是相同的,则不需要配置负载平衡。它会将负载分配给每个节点。

In round-robin, load-balancing will utilize each server equally.

在循环中,负载均衡将平均地使用每个服务器。

If one server is faster and more powerful than the other, you might want to use the weighted round-robin to configure more load on the faster server.

如果一个服务器比另一个服务器更快、更强大,那么您可能希望使用加权循环来在更快的服务器上配置更多的负载。

References:

引用:

http://docs.oracle.com/cd/E26576_01/doc.312/e24934/http-load-balancing.htm http://msdn.microsoft.com/en-us/library/ff648960.aspx

http://docs.oracle.com/cd/E26576_01/doc.312/e24934/http-load-balancing.htm http://msdn.microsoft.com/en-us/library/ff648960.aspx

更多相关文章

  1. MySQL数据切分、负载均衡和集群
  2. Finder3.0 - 集群支持即将发布
  3. Hadoop2.2集群安装配置-Spark集群安装部署

随机推荐

  1. 使用最新版AndroidStudio2.0进行NDK开发
  2. android 导入新工程或是编译没了android.
  3. Android远程服务编写和调用教程
  4. 谈谈关于Android视频编码的那些坑
  5. android中color的值
  6. Android手机操作系统中实现图片浏览
  7. 谷歌升级手机Android商城 趋向社交网络应
  8. Android的View类使用
  9. Android:Google的阳谋和Apache Harmony
  10. 图解 Android Handler 线程消息机制