实时数据更新有什么思路可以完成?
比如,实现一块区域专门进行最新留言的展示.. 每次有最新的留言就把它显示在上面..
(比如人人影视右下角的“精彩评论”, 不知道是不是实时的)
再比如,做一个网站,抓取其他网站上的信息,比如租房价格。
但是其他网站上的租房价格的更新并不是定时的。
对于这些实时更新的需求? 有什么思路可以完成?
回复内容:
比如,实现一块区域专门进行最新留言的展示.. 每次有最新的留言就把它显示在上面..
(比如人人影视右下角的“精彩评论”, 不知道是不是实时的)
再比如,做一个网站,抓取其他网站上的信息,比如租房价格。
但是其他网站上的租房价格的更新并不是定时的。
对于这些实时更新的需求? 有什么思路可以完成?
这个需求跟在线聊天类似
- ajax频繁请求
- 长轮询
可以看看这篇[文章](http://blog.leezhong.com/tech/2011/03...)
- websocket (开源swf库可以解决低版本浏览器的兼容,swf需要服务器端的一个授权)
swf开源库:[https://github.com/gimite/web-socket-...](https://github.com/gimite/web-socket-...)
这里我写了段简单的服务器端授权[代码](https://github.com/xiaozi/PolicyServe...)
如果服务端没有要求...node比较好点吧..
socket.io..多种方案,也支持多种浏览器
到现在为止的成熟方案似乎包括tornado, node, erlang, 另外不知道go实现的怎么样, python里面还有一堆gevent, greenlet可以用, twisted也可以考虑. PHP多线程或多进程就别想了.
在产品级别, 已知的比如 www.quora.com 是tornado, gtalk不知道如何实现, 可能是java?
mochimedia应该比较erlang
国内的腾讯阿里什么的就更不知道了, 他们都有做web chat的, zhihu.com也是tornado
http://segmentfault.com/q/10100000001...
我用socket.io解决了实时消息的问题。
Microsoft ASP.NET SignalR

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP makes it easy to create interactive web content. 1) Dynamically generate content by embedding HTML and display it in real time based on user input or database data. 2) Process form submission and generate dynamic output to ensure that htmlspecialchars is used to prevent XSS. 3) Use MySQL to create a user registration system, and use password_hash and preprocessing statements to enhance security. Mastering these techniques will improve the efficiency of web development.

To maximize the efficiency of learning Python in a limited time, you can use Python's datetime, time, and schedule modules. 1. The datetime module is used to record and plan learning time. 2. The time module helps to set study and rest time. 3. The schedule module automatically arranges weekly learning tasks.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Efficient training of PyTorch models on CentOS systems requires steps, and this article will provide detailed guides. 1. Environment preparation: Python and dependency installation: CentOS system usually preinstalls Python, but the version may be older. It is recommended to use yum or dnf to install Python 3 and upgrade pip: sudoyumupdatepython3 (or sudodnfupdatepython3), pip3install--upgradepip. CUDA and cuDNN (GPU acceleration): If you use NVIDIAGPU, you need to install CUDATool

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
