实时信息传递
Did you know that ground stations transmit signals to satellites 22,236 miles above the equator in geostationary orbits, and that those signals are then beamed down to the entire North American subcontinent? Satellite radios today serve hundreds of channels across 9,540,000 square miles. Unless you’re working at a secret military facility, deep underground, you can enjoy satellite radio everywhere.
你知道吗,地面站向赤道上空22,236英里的地球静止轨道上的卫星传输信号,然后这些信号被传送到整个北美次大陆?今天,卫星收音机在9,540,000平方英里的范围内提供数百个频道。除非你在地下深处的秘密军事设施工作,否则你可以在任何地方享受卫星广播。
Just like the satellites, Slack sends millions of messages every day across millions of channels in real time all around the world. If we look at the traffic on a typical work day, it shows that most users are online between 9am and 5pm local time, with peaks at 11am and 2pm and a small dip in between for lunch hour. Though the working hours are similar across regions, looking at the two peaks in the graph below, it is evident that prime time is not the same: It’s post-noon in some regions and pre-noon in other regions. Each colored line in the below graph represents a region.
就像卫星一样,Slack每天在世界各地的数百万个频道中实时发送数百万条信息。如果我们看一下一个典型工作日的流量,它显示大多数用户在当地时间上午9点到下午5点之间在线,上午11点和下午2点是高峰,中间的午餐时间会有一个小的下滑。虽然各地区的工作时间相似,但看下图中的两个高峰,显然黄金时间是不一样的:在一些地区是午后,在其他地区是午前。下图中的每条彩线代表一个地区。
In this blog post we’ll describe the architecture that we use to send real-time messages at this scale. We’ll take a closer look at the services that send the chat messages and various events to these online users in real time. Our core services are written in Java: They are Channel Servers, Gateway Servers, Admin Servers, and Presence Servers.
在这篇博文中,我们将描述我们用来在这种规模下发送实时消息的架构。我们将仔细研究向这些在线用户实时发送聊天信息和各种事件的服务。我们的核心服务是用Java编写的:它们是通道服务器、网关服务器、管理服务器和存在服务器。
Server overview
服务器概述
Channel Servers (CS) are stateful and in-memory, holding some amount of history of channels. Every CS is mapped to a subset of channels based on consistent hashing. At peak times, about 16 million channels are served per host. A “channel” in this instance is an abstract term...