Facebook的/ Gmail的一致好评网页客舱 - 什么是时下chatapp存储文本信息的好方法? [英] facebook/gmail alike web chatbox - what is a good way for nowadays chatapp to store text message?

查看:103
本文介绍了Facebook的/ Gmail的一致好评网页客舱 - 什么是时下chatapp存储文本信息的好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在建设一个Facebook的一致好评客舱,而我前进的道路上遇到的几个注意事项和问题。

I'm currently building a facebook alike chatbox, and I have encounter several considerations and problems along the way.

我一直在Google上搜寻有用的资源,所有的时间,喜欢简单客舱的例子或在线教程。

I had been googling useful resources all the time,like simple chatbox example or tutorial online.

我的目标是建设只是像Facebook / Gmail的客舱和 CometChat 之一,我知道它的努力,太多的事情缩放幕后,但我想要做的就是构建它尽可能的简单,并找出的Facebook / Gmail的客舱如何实现自己的聊天功能。

My goal is to build one just like facebook/gmail chatbox and CometChat, I know it's hard and too much thing to scale behind the scene, but all I want to do is building it as simple as possible, and figuring out how facebook/gmail chatbox implement their chat functionality.

进展:

我已经完成了类似Facebook的客舱结构,在那里我有侧边栏的右侧显示在线的朋友,我可以用聊天,弹出客舱底部,并且还能够扩展和最小化。

I have finished facebook-like chatbox structure where I have sidebar at the right displaying online friends i can chat with, and popup chatbox at the bottom, and it is able to expand and minimize it.

我也已经完成了简单的聊天基于MySQL数据库。 有4个列的发件人,接收器,信息,时间,用于存储会话表。 我的问题客舱的工作是这样的:

I also have finished simple chatting based on MySQL database. There's a table with 4 columns 'sender', 'receiver', 'message', 'time' for storing conversation. My chatbox works this way:

1,用户发送一条消息,我的前端的JavaScript将获取信息的用户类型,并通过Ajax将消息发送到PHP文件在服务器上。 2,后端PHP文件将这个信息存储到MySQL。 3.前端将调用更新功能,每3秒更新客舱的内容,如果接收器发送邮件给发件人,并显示在前端的聊天。

1.The user send a message, and my front-end javascript will fetch the message the user type in and send the message to php file on the server via Ajax. 2. backend php file will store this message to MySQL. 3. The front-end will call the update function every 3 seconds to update the chatbox content if receiver send message to the sender, and show it out in frontend's chat.

我不知道这是一个很好的方式和长期的方式做,我真的很关心。 如果用户的成长和壮大,我得想办法来扩展它好还是我的数据库和服务器会爆炸,前台用户可能会觉得高延迟的更新的交谈。

I'm not sure this is a good way and long way to do, and I'm really concerned about it. If users grow and grow, I have to think of ways to scale it well or my database and server will explode and frontend users might feel high latency in updating conversation.

时的BigTable一个正确的方式,如果你有百万计的用户在网上做到这一点?

Is BigTable a right way to do this if you have millions of users online?

如何Facebook的商店其客户的短信或聊天记录在后台好? 怎么样Whatapp聊天App Store上的短信? 它是能够让用户直接聊天的其他用户没有在服务器上存储状态?

How does facebook store their customer's text message or chat history in the backend well?? How does chat app like Whatapp store their text message? Is it able to let the users chat directly to another user without storing state in server?

如果我想实现我的客舱聊天记录的功能,有什么好办法吗? 我想到的是服务器可以在他们的文件系统中每个会话创建.txt文件,它有一个数据库表列来存储文件路径。这是一个很好的方式和正确的方式做的聊天记录,我知道它可能做这种方式,但林不知道,如果它是一个正确的方式还是不错的方式。

If I want to implement the chat history functionality in my chatbox, what is a good way to do ?? I am thinking server can create .txt file for each conversation in their file system, and it has a database table column to store the file path. Is this a good way and right way to do with chat history, I know its possible to do it this way, but im not sure if its a right way or good way.

我知道这可能是一个巨大的,详细的应用。 我问构建它不是一个详细的实施,但一个大的图片,概念!

I know this could be a huge, detailed application. I'm asking not a detailed implementation but a big picture, concept of building it!

谢谢!

推荐答案

这是一个很好的问题,这里是一个企图在回答吧。

That's a good question and here's an attempt at answering it.

我相信你太早考虑可扩展性一点。您的IM应用程序可能无法达到用户的预期数量为它停止执行良好。考虑提高你的小产品和的规模,你去作为需要一样多。

I believe you are thinking about scalability a bit too early. Your IM app might not reach the projected number of users for it to stop performing well. Consider enhancing your small product and scale as you go as much as is needed.

磁盘I / O是,你将面临扩展Web应用程序的问题之一。直接存储通信到磁盘txt文件可能不是一个可靠的解决方案。

Disk I/O is one of the issues that you will face scaling your web application. Storing communication directly onto the disk with txt file might not be a reliable solution.

按您的技术堆栈,以它的限制,然后才考虑改变它,或者切换到别的东西。我假设你使用的是关系型数据库用于存储(因为你提到的行和列,这不是一个最终的指标,但仍),还有其他的选择,在那里,有很好的标杆成绩在其他多个妥协为代价的。 (NoSQL的:你指的BigTable)是一种选择。关系数据库是伟大的,他们已经在相当长一段时间的行业标准,但目前也有另一种解决方案是非常有前途的。

Push your technology stack to its limits before considering changing it or switching to something else. I assume you are using a relational database for your storage (since you mentioned columns and rows, which is not an ultimate indicator but still), there are other options out there that have good benchmarking results at the expense of multiple other compromises. (NoSQL: which you referred to as BigTable) is one option. Relational databases are great, they have been for quite a long time the industry standard but currently there are alternative solutions that are quite promising.

。看看NoSQL的基于文档的datastorage解决方案,如 MongoDB的,的 CoucheDB 甚至卡桑德拉,并有许多其他。有相当数量的每个的性能的信息,根据具体情况和情况。选择什么是最适合的问题在手,也不是什么最时髦或庑殿式。

Look into NoSQL document based datastorage solutions such as MongoDB, CoucheDB or even Casandra and there are many others. There is a considerable amount of information about the performance of each, under specific circumstances and situations. Choose what is best for the problem at hand and not what is most fashionable or hipped.

另一种选择是为外包您的可扩展性问题,以第三方提供商,如火力地堡。在这种情况下你所担心的是你的产品,而不是什么引擎盖下发生的。

Another option would be to outsource your scalability problems to a 3rd Party provider such as Firebase. In this situation all you have to worry about is your product and not what's happening under the hood.

商店只需要和归档或者解聘你做什么,而不是数据。

Store only the data that you need and archive or dismiss what you don't.

使用的可扩展性通常有2大类:水平和垂直缩放。

With scalability there are generally 2 broad categories: Horizontal and Vertical scaling.

  1. 水平:意味着增加更多的节点到你的系统,即添加更多的服务器实例来处理额外的负担。有许多云计算解决方案提供商,在那里,使这一流派缩放非常便宜和瞬时的。

  1. Horizontal: means adding more nodes to your system i.e. adding more server instances to handle the extra load. There are many cloud solution providers out there that make this genre of scaling very cheap and instantaneous.

垂直:意味着添加更多的资源,您正在运行你的应用程序从除了使用特定的技术,使您可以充分利用你的资源全部优势的节点。这种优化发生在该实例资源的水平(即CPU,内存,磁盘空间等)与您的数据存储,编程语言的选择,您正在使用等算法......你可能会意识到,PHP和MySQL AREN吨这项工作的工具,但是这是值得商榷的。

Vertical: means adding more resources to the node you are currently running your app from in addition to use specific technologies that allow you to take full advantages of your resources. This optimization happens on the level of the instance resources (i.e. CPU, RAM, Disk Space etc...) and your data storage, programming language of choice, algorithms you are using etc... You might realize that php and mysql aren't the tools for this job, but that's arguable.

阅读更​​多关于它这里

分布式系统架构师/程序员还利用其它(快)编程语言运行时(如C,C ++或Java的连),以加速某些任务。看看你能如何剖析你的应用程序成更小的脱钩模块/可独立运行的组件。 (但我不知道,如果你永远不会达到这个阶段,IM客户端,除非它变得那么受欢迎了WhatsApp或Facebook聊天)。

Distributed Systems architects / programmers also take advantage of other (faster) programming languages at runtime (such as C, C++ or even Java) to speed up certain tasks. Look into how you can dissect your application into smaller decoupled modules / components that can run independently. (But i'm not sure if you will ever reach this stage with an IM client unless it becomes as popular as Whatsapp or Facebook chat).

我劝你抢,读几本关于扩展Web应用程序,并利用云计算。研究可扩展的架构和设计应用程序依赖于基于它们的业务逻辑。

I advise you to grab and read a couple of books about scaling web applications and leveraging cloud computing. Study scalable architectures and design your application depending on your business logic based on them.

这是一个非常广泛和复杂的话题,我相信其他人可能对这个问题的其他有趣的见解。

This is a very broad and complex topic, I'm sure others might have additional interesting insight on the matter.

这篇关于Facebook的/ Gmail的一致好评网页客舱 - 什么是时下chatapp存储文本信息的好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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