High Concurrency Website Solutions

A small website can be implemented using the simplest html static page, with some pictures to achieve beautification effect, all pages are stored in a directory, such a website has very simple requirements on system architecture and performance. With the continuous enrichment of Internet business, website-related technologies have been subdivided into very fine aspects after years of development. Especially for large-scale websites, the technologies used are very extensive, ranging from hardware to software, Programming languages, databases, WebServer, firewalls and other fields have high requirements, which are no longer comparable to the original simple html static website.

  Large-scale websites, such as portal websites, face a large number of user visits and high concurrent requests, and the basic solutions focus on the following links: using high-performance servers, high-performance databases, high-efficiency programming languages, and high-efficiency programming languages. Performance web container. These solutions to a certain extent mean greater investment.

1. HTML static

  In fact, we all know that pure static html pages are the most efficient and least expensive, so we try our best to use static pages to implement the pages on our website. This simplest method is actually the most effective method. However, for websites with a large amount of content and frequent updates, we cannot manually implement all of them one by one, so our common information publishing system CMS appears, such as the news channels of various portal sites we often visit, and even their other channels. It is managed and implemented by the information release system. The information release system can realize the simplest information entry and automatically generate static pages. It can also have functions such as channel management, authority management, and automatic crawling. For a large website, it has a set of efficient , a manageable CMS is essential.

  In addition to portal and information publishing type websites, for community type websites with high requirements for interactivity, as static as possible is also a necessary means to improve performance. Posts and articles in the community are made static and updated in real time. Re-staticization is also a strategy that is widely used at times. Mop’s hodgepodge uses such a strategy, as does the NetEase community.

  At the same time, html staticization is also a means used by some caching strategies. For applications that frequently use database queries in the system but the content update is small, you can consider using html staticization to achieve it. For example, the public setting information of the forum in the forum, the current mainstream forums can be managed in the background and stored in the database. In fact, a large number of these information are called by the foreground program, but the update frequency is very small, you can consider updating this part of the content in the background When it is static, it avoids a large number of database access requests.

2. Image server separation

  As we all know, for web servers, whether it is Apache, IIS or other containers, pictures are the most resource-intensive, so we need to separate pictures from pages. This is basically a strategy that large websites will use. They have Independent or even multiple image servers. Such an architecture can reduce the pressure on the server system that provides page access requests, and can ensure that the system will not crash due to image problems.

  Different configuration optimizations can be performed on the application server and image server. For example, when apache configures ContentType, it can support as few LoadModules as possible to ensure higher system consumption and execution efficiency.

3. Database cluster, database table hash

  Large websites have complex applications, and these applications must use databases. When faced with a large number of accesses, the bottleneck of the database will soon appear. At this time, a database will soon be unable to meet the application, so we need to use the database Cluster or library table hash.

  In terms of database clustering, many databases have their own solutions. Oracle, Sybase, etc. have good solutions. The commonly used Master/Slave provided by MySQL is also a similar solution. What kind of DB you use, please refer to the corresponding solution. solution to implement.

  The database cluster mentioned above is limited by the type of DB used in terms of architecture, cost, and scalability. Therefore, we need to consider improving the system architecture from the perspective of the application. Library table hashing is the most commonly used and most effective solution. .

  We install business and application or function modules in the application to separate the database, different modules correspond to different databases or tables, and then perform a smaller database hash for a page or function according to a certain strategy, such as user table, Hash the table according to the user ID, which can improve the performance of the system at low cost and has good scalability.

  sohu的论坛就是采用了这样的架构,将论坛的用户、设置、帖子等信息进行数据库分离,然后对帖子、用户按照板块和ID进行散列数据库和表,最终可以在配置文件中进行简单的配置便能让系统随时增加一台低成本的数据库进来补充系统性能。

4、缓存

  缓存一词搞技术的都接触过,很多地方用到缓存。网站架构和网站开发中的缓存也是非常重要。这里先讲述最基本的两种缓存。高级和分布式的缓存在后面讲述。

  架构方面的缓存,对Apache比较熟悉的人都能知道Apache提供了自己的缓存模块,也可以使用外加的Squid模块进行缓存,这两种方式均可以有效的提高Apache的访问响应能力。

  网站程序开发方面的缓存,Linux上提供的Memory Cache是常用的缓存接口,可以在web开发中使用,比如用Java开发的时候就可以调用MemoryCache对一些数据进行缓存和通讯共享,一些大型社区使用了这样的架构。另外,在使用web语言开发的时候,各种语言基本都有自己的缓存模块和方法,PHP有Pear的Cache模块,Java就更多了,.net不是很熟悉,相信也肯定有。

5、镜像

  镜像是大型网站常采用的提高性能和数据安全性的方式,镜像的技术可以解决不同网络接入商和地域带来的用户访问速度差异,比如ChinaNet和EduNet之间的差异就促使了很多网站在教育网内搭建镜像站点,数据进行定时更新或者实时更新。在镜像的细节技术方面,这里不阐述太深,有很多专业的现成的解决架构和产品可选。也有廉价的通过软件实现的思路,比如Linux上的rsync等工具。

6、负载均衡

  负载均衡将是大型网站解决高负荷访问和大量并发请求采用的高端解决办法。
  负载均衡技术发展了多年,有很多专业的服务提供商和产品可以选择,我个人接触过一些解决方法,其中有两个架构可以给大家做参考。

(1)、硬件四层交换

  第四层交换使用第三层和第四层信息包的报头信息,根据应用区间识别业务流,将整个区间段的业务流分配到合适的应用服务器进行处理。

  第四层交换功能就像是虚IP,指向物理服务器。它传输的业务服从的协议多种多样,有HTTP、FTP、NFS、Telnet或其他协议。这些业务在物理服务器基础上,需要复杂的载量平衡算法。在IP世界,业务类型由终端TCP或UDP端口地址来决定,在第四层交换中的应用区间则由源端和终端IP地址、TCP和UDP端口共同决定。

  在硬件四层交换产品领域,有一些知名的产品可以选择,比如Alteon、F5等,这些产品很昂贵,但是物有所值,能够提供非常优秀的性能和很灵活的管理能力。“Yahoo中国”当初接近2000台服务器,只使用了三、四台Alteon就搞定了。

(2)、软件四层交换

  大家知道了硬件四层交换机的原理后,基于OSI模型来实现的软件四层交换也就应运而生,这样的解决方案实现的原理一致,不过性能稍差。但是满足一定量的压力还是游刃有余的,有人说软件实现方式其实更灵活,处理能力完全看你配置的熟悉能力。

  软件四层交换我们可以使用Linux上常用的LVS来解决,LVS就是Linux Virtual Server,他提供了基于心跳线heartbeat的实时灾难应对解决方案,提高系统的强壮性,同时可供了灵活的虚拟VIP配置和管理功能,可以同时满足多种应用需求,这对于分布式的系统来说必不可少。

  一个典型的使用负载均衡的策略就是,在软件或者硬件四层交换的基础上搭建squid集群,这种思路在很多大型网站包括搜索引擎上被采用,这样的架构低成本、高性能还有很强的扩张性,随时往架构里面增减节点都非常容易。

  对于大型网站来说,前面提到的每个方法可能都会被同时使用到,这里介绍得比较浅显,具体实现过程中很多细节还需要大家慢慢熟悉和体会。有时一个很小的squid参数或者apache参数设置,对于系统性能的影响就会很大。

7、最新:CDN加速技术

什么是CDN?

   CDN的全称是内容分发网络。其目的是通过在现有的Internet中增加一层新的网络架构,将网站的内容发布到最接近用户的网络“边缘”,使用户可以就近取得所需的内容,提高用户访问网站的响应速度。

  CDN有别于镜像,因为它比镜像更智能,或者可以做这样一个比喻:CDN=更智能的镜像+缓存+流量导流。因而,CDN可以明显提高Internet网络中信息流动的效率。从技术上全面解决由于网络带宽小、用户访问量大、网点分布不均等问题,提高用户访问网站的响应速度。

CDN的类型特点

   CDN的实现分为三类:镜像、高速缓存、专线。

  镜像站点(Mirror Site),是最常见的,它让内容直接发布,适用于静态和准动态的数据同步。但是购买和维护新服务器的费用较高,还必须在各个地区设置镜像服务器,配备专业技术人员进行管理与维护。对于大型网站来说,更新所用的带宽成本也大大提高了。

  高速缓存,成本较低,适用于静态内容。Internet的统计表明,超过80%的用户经常访问的是20%的网站的内容,在这个规律下,缓存服务器可以处理大部分客户的静态请求,而原始的服务器只需处理约20%左右的非缓存请求和动态请求,于是大大加快了客户请求的响应时间,并降低了原始服务器的负载。

  CDN服务一般会在全国范围内的关键节点上放置缓存服务器。

  专线,让用户直接访问数据源,可以实现数据的动态同步。

CDN的实例

  举个例子来说,当某用户访问网站时,网站会利用全球负载均衡技术,将用户的访问指向到距离用户最近的正常工作的缓存服务器上,直接响应用户的请求。

  当用户访问已经使用了CDN服务的网站时,其解析过程与传统解析方式的最大区别就在于网站的授权域名服务器不是以传统的轮询方式来响应本地DNS的解析请求,而是充分考虑用户发起请求的地点和当时网络的情况,来决定把用户的请求定向到离用户最近同时负载相对较轻的节点缓存服务器上。

  通过用户定位算法和服务器健康检测算法综合后的数据,可以将用户的请求就近定向到分布在网络“边缘”的缓存服务器上,保证用户的访问能得到更及时可靠的响应。

  由于大量的用户访问都由分布在网络边缘的CDN节点缓存服务器直接响应了,这就不仅提高了用户的访问质量,同时有效地降低了源服务器的负载压力。

附:某CDN服务商的服务说明

 


采用GCDN加速方式

  采用了GCDN加速方式以后,系统会在浏览用户和您的服务器之间增加一台GCDN服务器。浏览用户访问您的服务器时,一般静态数据,如图片、多媒体资料等数据将直接从GCDN服务器读取,使得从主服务器上读取静态数据的交换量大大减少。

  为VIP型虚拟主机而特加的VPN高速压缩通道,使用高速压缩的电信<==>网通、电信<==>国际(HK)、网通<==>国际(HK)等跨网专线通道,智能多线,自动获取最快路径,极速的动态实时并发响应速度,实现了网站的动态脚本实时同步,对动态网站有一个更加明显的加速效果。

  每个网络运营商(电信、网通、铁通、教育网)均有您服务器的GCDN服务器,无论浏览用户是来自何处,GCDN都能让您的服务器展现最快的速度!另外,我们将对您的数据进行实时备份,让您的数据更安全!

 

转自:http://hi.baidu.com/%BD%A3%CA%A5_%B7%A8%CA%A6/blog/item/6c933c0a92b8630a94ca6bd7.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326612143&siteId=291194637