Sun game server (SGS)

Source: Internet
Author: User
Sun game server (SGS)

ArticleClassification: Java programmingKeywords: Flex game

 

Sun game server (SGS) is an open-source project of sun, mainly designed for server-side development of MMO games. I first learned about the SGS project from the blog article (http://nighthaven.javaeye.com/blog/181431) of nighthaven, and after a general understanding of the functions it provided, I became interested in it. After a period of research, I have some experiences. the following is a summary of these experiences. At last, we will provide a server battle against Russia using SGS.

SGSMain functions provided:

Server Expansion: The traditional expansion method is to divide the entire game area into multiple zones, and different zones run on different game servers. there are two problems. One is that players in different zones cannot interact with each other, and the other is that if there are few actions in a zone, the server resources may not be fully utilized. in SGS's processing mode, all processing is divided into small execution units (called tasks), which can be executed on any SGS server that makes up the network, when a user increases, the system automatically adds processing threads and does not need to allocate different zones to different servers for expansion. this not only improves resource utilization, but also enables interaction between all players.

Data Integrity: SGS provides a distributed data storage. When a task needs to access data, it accesses data through the data storage API. Data Access supports transactions. When two tasks conflict, SGS will automatically coordinate and reschedule younger tasks to wait for execution, while older tasks will be executed until the end. in the current version, SGS data storage does not use relational databases, but uses Berkeley dB. any Java object can be automatically stored transparently after the managedobject and serializable interfaces are implemented. (The storage mechanism of SGS seems to be scalable. Someone has discussed the storage plug-in of MySQL on the Forum)

Simple programming model: From the Perspective of application development, SGS provides APIs to shield most of the underlying complexity, such as thread scheduling, transaction processing, and so on.ProgramYou only need to develop and assemble your own objects, listen to and respond to client events, and manage your own persistent managedobject object lifecycle.

Two Communication ModelsOne is client/server communication, that is, each client only communicates with the server, and the server is responsible for data processing and forwarding. the other is the channel mechanism (similar to one-to-multiple broadcast). The channel is created and maintained by the server, and multiple clients can be added to each channel, the server can listen to all the communications in the channel or the communications of a specific client. you can also send messages to all or some clients in the channel. the client that joins the channel can receive messages sent by any other client. communication between clients under the channel does not require server intervention. because all communication data formats are byte arrays, applications need to develop their own application layer protocols.

Scalable Mechanism: The SGS application accesses data and uses channel to create tasks through "manager. there are currently three default "managers", datamanager, channelmanager, and TASKMANAGER. however, you can expand and develop your own manager. For example, in SGS, the task should be executed as quickly as possible (the maximum time allowed by the task can be configured ), therefore, if you call a system method that may cause blocking, You need to develop an extended manager.

Currently SGS provides C and Java client libraries, but the Protocol is open and someone has developed a client library (https://darkstar-as-client.dev.java.net/) that supports as3 and python /).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.