问题标签 [horizontal-scaling]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
123 浏览

database - 扩展数据库和服务器

如果你的服务器和数据库流量太大,比如说一个简单的在线游戏,你会如何考虑扩展服务器和数据库?

我的想法是面向未来并横向扩展服务器和数据库。我知道这会产生更大的复杂性,但我觉得这是最好的选择。

有人可以给我他们的想法吗?您将如何识别数据库中的瓶颈和问题?在进入和扩展之前要寻找的主要内容是什么?您将如何扩展服务器?您将如何扩展数据库?

谢谢 :)

0 投票
0 回答
216 浏览

ios - 如何处理对单个服务器的大量请求?

我正在处理我的这个个人项目,其中涉及一个 iOS 应用程序,该应用程序每天从我家的服务器检索数据(整数值)。现在我有一个服务器,每秒只能处理大约 100-120 个并发请求。但是,由于我的预算有限,我想扩展我的设置以便能够同时处理多达 70-80K 个请求,同时使用最少的服务器。任何人都可以为此建议一些技术吗?

0 投票
1 回答
205 浏览

mysql - Scaling a Server Horizontally

I have a question about scalability. Let's say I have a multiplayer game, such as Uno, where the server handles everything. (Assume this is a text-only game for simplicity). For example, to get information printed out to the user in the client, the server might send PRINT string, or CHOOSE data (to pick a card to play), etc. In this regard, the client is "dumb" and the server handles the game logic.

A quick example of how this might work on a protocol level:
Server sends: PRINT Choose a card
Server sends: CHOOSE Red 1,Blue 1 (user shown a button or something, and picks Red 1)
Client sends: Red 1

Let's say I have this architecture:
Player Class: stores the cards the user has, maybe some methods (such as tellData(String data) which would send PRINT data, sendPM() which could private message a user)

Server Class: handles authentication, allows users to create new games, shows users a list of games they can join

Game Class: handles users playing a card, handles switching to a new player for his or her turn, calls methods on player class like tellData(), pickCard(), etc

How would I scale this, to run the server on multiple computers? Right now, all of the users connect to one server, and require the Player, Server, and Game class to interact with each other. If someone could provide some suggestions, and/or point me to some good resources/books on this, it would be greatly appreciated (no, this is not a homework assignment or something for a business, this is just a personal project and curiosity of mine). In terms of scalability, I'd like to just be able to add another server, and handle the additional load of players--but the most concurrent connections would be 1000.

Also, would this become significantly more difficult of a scalability challenge if we added in more games?

Furthermore, what is the best way to store game data? In a SQL database, or serializing objects, or what? By this, I mean let's say 3 users are in a game of Uno, and want to return to it later. I don't want to store their cards and information about the game in the Player/Server/Game class (RAM) forever - I want to dump this somewhere, so when the user logs in, the info can be loaded from however this was dumped into RAM, and then the appropriate Player/Game objects.

Finally, how can I make changes to the server without having to kill it, and restart it? Assume the server was written in Java or Python.

If anyone can provide suggestions or some resources it would be greatly appreciated - this includes changing the architecture I originally stated.

Thanks for any and all help!!

EDIT: Are there any good books or talks you all would recommend on the subject?

0 投票
1 回答
489 浏览

php - php cURL 是否会耗尽 RAM 或处理器电源?

我目前有一个使用 PHP cURL 每分钟同时下载数百页的爬虫脚本。

我进行了设置,以便有一个主服务器和几个远程服务器使用PHP cURL下载页面并使用远程 MYSQL 连接将数据发送回(然后将数据保存在主服务器中)。

我正在尝试优化和降低这些服务器的成本;那么我应该水平缩放还是垂直缩放?我应该寻找更多的 RAM 或处理器能力吗?

任何帮助表示赞赏。

0 投票
1 回答
1227 浏览

node.js - 在 Heroku 和 Node.js 上扩展 websockets

假设我有一个大型应用程序在 Heroku 上处理大量 websockets 连接。为了应对如此大的需求,测功机的数量增加到N.

Heroku 的路由器将如何在正在运行的测功机之间分配新的传入 websockets 连接?

换句话说,如果其中一个 dyno 在 websockets 连接中被最大化,Heroku 的路由器是否会在其他(据说)不太忙的 dyno 之间偏离所有新的传入请求?或者它是否仍将使用文档中所述的随机分配来进行 http 传入连接

这绝对是有道理的,因为 websockets 连接首先是 http 连接。N然而,在运行的测功机之间均匀地扩展大量持久连接将是相当复杂的。

有人确认吗?

0 投票
3 回答
1430 浏览

nosql - 传统 RDBMS 中的水平扩展

我刚刚遇到了 NoSQL 系统,它们具有所有天赐的优势。其中之一似乎是毫不费力的水平缩放。我的问题是,为什么像 MySQL 或 SQL Server 这样的经典 RDBMS 不能进行水平扩展?还是无法达到与 NoSQL 系统相同的程度?

0 投票
1 回答
270 浏览

mysql - 通过 ActiveRecord 将查询分布到多个数据库

我有一个多主 MySQL 集群,我想通过使用负载均衡器将来自我的 Rails 项目的读/写查询分发到多个服务器。

问题是,据我所知,Rails 试图在服务器的生命周期内保持连接对象处于活动状态。但是,HAProxy 仅在每个查询打开新连接时才分发查询。这不是我想要的。我希望基于每个查询而不是每个连接进行分发。

在每个查询的基础上将 Rails 查询从我的服务器分发到多主服务器时,我有哪些选择?

注意:这是一种高可用性情况,我们不确定是否每个 sql server 都始终处于运行状态。这就是我使用 haproxy 的原因。

0 投票
0 回答
75 浏览

java - 缩放问题:NIO 中的选择器

我使用过的场景SelectorIO multiplexing

我们有一个主要内容服务器和 100 个辅助内容服务器。辅助服务器发送更改的内容元信息,以便主服务器将更新所有最新的内容信息。最初的设计是为 100 个打开的套接字使用 100 个线程,这些套接字是一对一映射到辅助服务器的。但是由于我们想支持更多的辅助服务器,我改变了设计使用Selectors,以便一个线程执行 IO 多路复用(selector.select())并将其发送SelectionKey到工作线程池(大小为 50 的固定线程池)。最快乐的部分是设计工作。

实施这两个问题后,我想到的是:

  • 如果辅助内容服务器在一秒钟内轰炸了 100/1000 次请求,这种设计是否可行(目前我们每个辅助内容服务器每秒收到 5 到 7 个请求)?因为我觉得上面的设计只不过是把你的问题推到了下一层,但问题仍然存在。我对么?

  • 上述设计只是解决了将辅助服务器的数量从 100 扩展到 500 的问题,但如果我想将每秒请求(即从 5req/sec 到假设 1000 req/sec)扩展,它不会解决问题。

0 投票
1 回答
54 浏览

mongodb - 在 sharded mongodb 中保留文档

我在 mongodb 中有一个分片的文档集合,并且有几个应用程序服务器在访问它。

每个应用程序都会贡献新文档,最终还需要删除一些文档。

删除哪些文档并不重要,但重要的是它删除(声明)一个确切的数字,并且没有其他应用程序正在删除(声明)相同的文档。

我的想法是:

此解决方案的一个潜在问题是,如果应用程序太多(而文档很少),他们只会继续声明一些文档并再次发布它们。

这个问题的众所周知且经过充分测试的解决方案是什么?

“update”和“findAndModify”是否保证更新后的文档与更新前的查询匹配?

或者另一个应用程序是否可以在匹配和更新之间“窃取”它,因此两个应用程序都认为他们已经声明了该文档?

0 投票
1 回答
183 浏览

java - 2路ssl tomcat无状态服务规模

我在 java 中有一个无状态服务,部署在一个 tomcat Web 服务器中,并且我还配置了 2 路 ssl 身份验证。到目前为止,一切正常。当我有一个新客户端时,我只需将新客户端证书放入我的信任并重新启动我的服务,新客户端就可以使用我的服务。

但是我需要水平扩展,因为我的服务是无状态的,这没问题,但是如果我有 10 台服务器,我不想去每台服务器并在每个 trustore 文件中进行此更改。

有任何想法吗?