English 中文(简体)
如何根据特定资源途径实现尽可能公平的负荷平衡
原标题:How to perform an as fair as possible load balancing based on specific resource paths

我的申请书是用于从档案(作为图像从PDF文档中下载的页面)中制作的工艺品,而原始的PDF文件则在S3上存,当客户打其中一人时,被下载到产生图像的服务器上。 这些机器有一个地方教学机制,保证每个国防军档案只下载一次。

因此,当客户收到要求give me page 1 of pdf>时,如果那里没有pdf档案,就会从S3下载,并储存在当地海滩上,然后一个过程生成第1页,并向客户发送图像。

客户本身并不了解它与特殊服务器的连接,他们都认为自己只是访问网站服务器,但为了业绩,我要确保该客户总是被带往符合其首次要求(从S3下载档案)。

我只能给客户设置一个厨师,让他总是从该具体档案服务器下载,但把这一数据放在客户身上会导致不公平的使用,因为一些用户将打开许多文件,有些用户不想在资源层面进行这一负荷平衡(PDF文件)。

每个文件都有独特的识别特征(数据库中的主要关键人物),我的第一个解决办法是利用红利,将文件编为钥匙,其价值是目前文件有线搭桥的服务器机的主机,但我要去掉红,或寻找更简单的方式来实施,而不需要在其他地方寻找钥匙。

Also, it would be nice if the defined algorithm or idea would allow for adding more file servers on the fly.

如何以资源为基础,以富裕程度平衡这种负荷?

仅为了说话,这是鲁比拉、 j瓦和恰帕斯的混合体。

最佳回答

I d 在负荷平衡中采用以下做法:

  • Strip the requested resource URL to remove the query and fragment parts.
  • Turn the stripped URL into a String and take its hashcode.
  • 利用散列代码从现有服务器名单中选择后端服务器;例如

    String[] serverNames = ...
    String serverName = serverNames[hash % serverNames.length];
    

这把负荷平均分布在所有服务器中,并且总是向同一服务器发出同样的要求。 如果增设更多的服务器,则会进行调整......尽管你在再次 warm升时把业绩打到一起。

I don t think you want to aim for "fairness"; i.e. some kind of guarantee that each requests takes roughly the same time. To achieve fairness you need to actively monitor the load on each backend and dispatch according to load. That s going to (somewhat) negate the caching / affinity, and is going to consume resources to do the measurement and load-balancing decision making. A dumb load spreading approach (e.g. my suggestion) should give you better throughput overall for your use-case.

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签