使用用于移动平台的套接字在Java中实现实时聊天应用程序是否好 [英] is it good to implement real time chat application in java using sockets for mobile platforms

查看:72
本文介绍了使用用于移动平台的套接字在Java中实现实时聊天应用程序是否好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过3lac与目标用户一起设计一个移动聊天应用程序,我已经看到了有关XMPP服务器和客户端方法以及使用socket.io的node.js的文章,但是这种困惑会扩大到如此之多用户.

I am trying to design a mobile chat application with a targeted user over 3lac, I have seen articles related to XMPP server and client approach, node.js with socket.io, but the confusion is which will scale up for so many users.

使用java套接字api还可以为这么多用户实现吗?

Can this also be achieved using java socket api for so many users.

推荐答案

与具有相关语言的开发人员的技能和解决方案的设计相比,实现语言对解决方案的可伸缩性影响很小.

The implementation language has little impact on the scalability of the solution when compared to the skill of the developers with the language in question, and the design of the solution.

在使用聊天程序时,扩展的两个主要挑战是1) C10K问题 2)在社交图表(O(numPeople*numPeopleSubscribedToPerson*numDevicesPerPerson*rateOfInteractions))中缩放实时通知.

The two main scaling challenges when working on a chat program are 1) the C10K problem and 2) scaling real time notifications in a social graph, which is O(numPeople*numPeopleSubscribedToPerson*numDevicesPerPerson*rateOfInteractions).

研究facebook,twitter和gmail设计将帮助您了解与缩放消息增长速率有关的问题以及如何为Web解决方案建模(提示:使用推/长轮询Web技术,并且优先使用异步解决方案而不是阻止同步一个是要走的路).

Researching facebook, twitter and gmail designs will help you to understand problems the with scaling the rate of message growth and how to model a solution for the web (hint: use push/long polling web techniques and favoring asynchronous solutions over blocking synchronous ones is the way to go).

此链接是一个很好的开始 facebook,gmail如何发送实时通知?,并且Varnish在此处记录其对C10K问题的解决方案 a>.

This link is a good start How does facebook, gmail send the real time notification? and Varnish documents their solution to the C10K problem here.

就Java套接字而言,它们很好.但是,常见的陷阱在于线程处理.避免为每个套接字分配一个线程.这将影响大约1-10k用户的扩展问题,具体取决于包括操作系统配置在内的一些因素.使用Java时,请使用Java NIO,并确保线程使用率不会随着登录服务器的用户数量的增加而增加.

As far as Java Sockets go, they are fine. However the common gotcha is with the thread handling. Avoid allocating one thread per socket. That will hit scaling problems at around 1-10k users depending on a few factors including OS configuration. When using Java, go with Java NIO and make sure that the thread usage does not grow with the number of users logged in to the server.

诸如node.js之类的语言的优势在于,它们从一开始就倡导这些最佳实践,而在Java世界中,优秀的异步技术却迟来了.但是它们确实存在.

The advantage of languages like node.js is that they advocate these best practices from the beginning, where as good asynchronous techniques were late to the game in the Java world. But they do exist.

这篇关于使用用于移动平台的套接字在Java中实现实时聊天应用程序是否好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆