Explore the possibility of using memcache to implement chat rooms. How to Solve

Source: Internet
Author: User
Explore the possibility of using memcache to implement chat rooms.
Suddenly think of this topic, of course, to do complex is certainly not, we only explore the text through the memcache implementation of the chat application possible.
First of all in front of us is how to maintain this key? Is there any possibility of implementation?

------Solution--------------------
Because of the need to record chat content and chat people information
So each piece of data should be a "structure" rather than a single value

Because the chat content is not modifiable, so key does not make sense, increment can
At most, take the time value.
------Solution--------------------
There are not many things that a chat room needs to cache.
------Solution--------------------
Studied Python's chat room ... Take a look.
------Solution--------------------
Come in and learn, this piece has no experience.
------Solution--------------------
Originally chat room is a function of egg ache. How much capital to spend.

There are many ways to achieve this without experience. The chat data is stored in the database or local file or memcache, the display data will be used to push. I hear you can also use sockets to achieve. It hasn't been tested. Do not know which kind of efficiency is high.
------Solution--------------------
discuss
Originally chat room is a function of egg ache. How much capital to spend.

There are many ways to achieve this without experience. The chat data is stored in the database or local file or memcache, the display data will be used to push. I hear you can also use sockets to achieve. It hasn't been tested. Do not know which kind of efficiency is high.

------Solution--------------------
Although you do not understand the web, it is possible to run fcgi as a separate chat server.
------Solution--------------------
discuss

Reference:
Originally chat room is a function of egg ache. How much capital to spend.

There are many ways to achieve this without experience. The chat data is stored in the database or local file or memcache, the display data will be used to push. I hear you can also use sockets to achieve. It hasn't been tested. Do not know which kind of efficiency is high.


It's nice to make long connections with WebSocket!

------Solution--------------------
discuss

Although you do not understand the web, it is possible to run fcgi as a separate chat server.

------Solution--------------------
Unless the browser or flash itself is a server, if there is an open port, the push technology may come true.

HTTP is a request-response type. If it is a URI, it can be requested.

Guess QQ, each user has a friend's port.
There are two ways to achieve this: one is to have a central database, and the other is to speak to a user and then broadcast to the group.


------Solution--------------------
A substitute for memcached?
Redis bar, data into memory, but also support persistent on the hard disk, configuration is normal, the performance is probably memcached 10 times times (online data, I did not hit the test, but more than 5 times times is confirmed).

In addition, the chat room is feasible, and there are similar code, the Redis official website has an example, is completely redis to do the Imitation Twiiter page. Project name seems to be called "Retwis"

Have seen the design before, the general key is to use the hash value, such as the user name _ time and then MD5 ...
------Solution--------------------
Explore

Unless the browser or flash itself is a server, if there is an open port, the push technology may come true.

HTTP is a request-response type. If it is a URI, it can be requested.

Guess QQ, each user has a friend's port.
There are two ways to achieve this: one is to have a central database, and the other is to speak to a user and then broadcast to the group.

------Solution--------------------
Time stamp to do key

Because the value of mem is a size-limited

You can generate a key every time and then the JSON format is inside.

For example
One key per five minutes
And put the chats in the mem for five minutes.

The user then logs in based on the current timestamp to query
I wonder if I can
------Solution--------------------
Well, well, from the current experience, if a single server to do, the private thought that the long connection is inappropriate, short-connect chat room can achieve more traffic.

Suppose a 16 core 16G server, Nginx + php-fcgi words, probably reliable concurrency can reach 3W, so long connection, the maximum is 3W users? (3W is my own test of the situation, I slag ....) But also refer to the Zhang Yi blog, let the pioneers of the domestic Nginx bar, but the short connection, see Nginx per second the most request and back-end storage capacity of the most request per second

The following is a separate request capability test for Nginx and Redis:
Nginx, with phpinfo.php as the test content

PHP Code
./webbench-c 10000-t "http://127.0.0.1/test.php" Webbench-simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-200 4, GPL Open Source Software.Benchmarking:GET http://127.0.0.1/test.php10000 clients, running Sec. speed=230470 pages/min, 46263036 bytes/sec. requests:115235 susceed, 0 failed.
------Solution--------------------
Not having done that, it's very stressful.

Explore

Well, well, from the current experience, if a single server to do, the private thought that the long connection is inappropriate, short-connect chat room can achieve more traffic.
  • 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.