Large data volume, high concurrency website solution

A small website can be realized by 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. 1. HTML static

        In fact, as we all know, pure static html pages are the ones with the highest efficiency and the least consumption, 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. 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. 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's forum adopts such a structure, which separates the forum's users, settings, posts and other information from the database, and then hashes the database and tables for posts and users according to the section and ID, and finally can be simply configured in the configuration file. A low-cost database can be added to the system at any time to supplement system performance.

  4. 4. Cache

      The term cache has been touched by technology, and cache is used in many places. Caching in website architecture and website development is also very important. Here are the most basic two types of caches. Advanced and distributed caching is described later.

      For caching in terms of architecture, those who are familiar with Apache can know that Apache provides its own caching module, and can also use the additional Squid module for caching, both of which can effectively improve Apache's access response capabilities.

      For the cache of website program development, the Memory Cache provided on Linux is a common cache interface that can be used in web development. For example, when developing in Java, you can call MemoryCache to cache and share some data. Some large communities use it. such a structure. In addition, when using web language development, various languages ​​basically have their own cache modules and methods, PHP has Pear's Cache module, Java has more, and .net is not very familiar, I believe there must be. (.net is System.HttpRuntime.Cache, but the premise is that you must reference System.Web.dll. This also shows that the object System.Web.Caching.Cache can be completely separated from the namespace System.Web, and Exists as a standalone caching framework.)

  5. 5. Mirror

      Mirroring is a method often used by large websites to improve performance and data security. The mirroring technology can solve the difference in user access speed caused by different network access providers and regions. For example, the difference between ChinaNet and EduNet has prompted many websites to A mirror site is built in the education network, and the data is updated regularly or in real time. In terms of the detailed technology of mirroring, I will not elaborate too deep here. There are many professional ready-made solution architectures and products to choose from. There are also cheap software implementation ideas, such as tools such as rsync on Linux.

  6. 6. Load Balancing

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

    (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. 7. 最新:CDN加速技术

    什么是CDN?

      CDN的全称是Content Delivery Network,即内容分发网络。CDN的通俗理解就是网站加速,CPU均衡负载,可以解决跨运营商,跨地区,服务器负载能力过低,带宽过少等带来的网站打开速度慢等问题。 

  8.     CDN的基本思路是尽可能避开互联网上有可能影响数据传输速度和稳定性的瓶颈和环节,使内容传输的更快、更稳定。通过在网络各处放置节点服务器所构成的在现有的互联网基础之上的一层智能虚拟网络,CDN系统能够实时地根据网络流量和各节点的连接、负载状况以及到用户的距离和响应时间等综合信息将用户的请求重新导向离用户最近的服务节点上。其目的是使用户可就近取得所需内容,解决 Internet网络拥挤的状况,提高用户访问网站的响应速度。

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

    CDN的类型特点

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

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

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

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

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

    CDN的实例

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

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

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

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325411062&siteId=291194637