也 10 年前的一篇文章,针对《对.NET 系统架构改造的一点经验和教训》一文的技术要点看法。
【对.NET 系统架构改造的一点经验和教训】里面的几条对 CSDN 的改造的技术要点如下:
- The data layer abandons the SQL Server database and stored procedures and migrates them all to the MySQL database on the Linux platform;
- Caching no longer relies on the caching mechanism provided by. NET itself and is migrated to distributed Redis deployed on the Linux platform;
- Calls between services should be avoided using. NET's own proprietary protocol and replaced with Restful HTTP Web API calls;
- Static resource requests are no longer handled by IIS itself, but are separated from Nginx on the Linux platform for processing;
- The file system that needs to be read is also changed to access the distributed file system on the Linux platform;
- The Windows server that deploys. NET code is placed behind the LVS, and the LVS is used for Load Balancer and failover.
1. Should the database use SqlServer or Mysql
As a web program, the web side has never been a bottleneck, but the bottleneck has always been on the data side. According to normal logic,. net executes faster than php because. net is compilable and php is interpretive. But many large websites are currently deployed under php. The main reason is that there are many ready-made solutions for php.
If there is a problem with a system, it is never a problem with the language, but a problem with the architecture, or the architect. As a web service, the bottleneck most of the time is in the database. Some children's shoes talk about the expensive authorization of the sqlserver database. You can go to qinfo and find a lecture given by Dazhong Dianping. They use asp.net and the mysql database. In essence, SqlServer and MySQL are both structured databases, which are not much different to developers. The scalability of the database is roughly 1) separation of read and write of the database 2) horizontal partitioning of the business 3) vertical partitioning of large tables. The rest is the realization of the details
2. Is the cache self-cached or distributed cached?
CSDN has migrated caching to Redis. Personally, I don't think this is a problem with. net's own caching mechanism. If you do distributed caching, whether you use Memcache or Redis, there are machines in between, which will definitely not be as fast as web server caching. If the traffic volume is small, it is actually not cost-effective to use a caching server to replace the web's own caching mechanism. When the system traffic reaches a certain level, its own caching mechanism can no longer meet the system's requirements, so it is definitely necessary to switch to the caching server. Of course, I don't think anyone will use a windows server as a cache server. Whether it's. net, java or php. Is there a performance difference when using memchace/Redis? The first revision of CSDN should be the blog system, which is the same as the blog system in the Blog Park. However, the revisions and modifications are no longer the original version. However, it's hard to imagine how CSDN's blog had such a large number of users using. net's own cache. Looking at the blog park Yunlu article, you know that the blog park uses memcached cache.
My understanding is that when the number of users is small, the web's own caching mechanism can be used. When it reaches a certain order of magnitude, the own caching mechanism cannot meet the needs of large amounts of data caching, you need to switch to distributed caching components. The principle to be followed is to bring data closer to users. Nowadays, many Internet services use memcached or similar key-value databases to put all data in the cache. However, structured databases such as mysql are only used as backup of the database. Data will be read from the database when the cache fails.
3. Choice of system protocol
Microsoft likes to add its own things to some protocols, and only its own set of solutions can be used. It is really convenient for selecting a full set of Microsoft products, but when we need to use non-Microsoft things, we made a mistake. Among web services, there are mainly http services such as web services or wcf. Webservice is a set of public standards, a set of protocols in xml format.
Web Services is a new technology that allows different applications running on different machines to exchange data or integrate with each other without the need for additional, specialized third-party software or hardware. Applications implemented in accordance with the Web Service specification can exchange data with each other, regardless of the language, platform, or internal protocol they use. A Web Service is a self-describing, self-contained available network module that can perform specific business functions. Web services are also easy to deploy because they are based on some general industry standards and existing technologies such as XML and HTTP. Web services reduce the cost of application interfaces. Web Services provide a common mechanism for the integration of business processes across an enterprise and even across multiple organizations.
In web transmission, json is a format that is shorter than the xml format and can be natively supported by js. Moreover, there is a lot of support from third parties. Choosing json as the carrier is better than xml. Restful is more of a data access style for me. Make url requests clearer. Not an agreement. So in the web system, I prefer to use Restful style APIs and json as carriers when making APIs. If the full set is Microsoft products, I think wcf Microsoft products are still the best choice.
4. Selection of file system
The file server is better than weindus under linux. At the very least linux does not have to deal with various file fragments. Well, I have never played file services before, so it's hard to comment.
5. Are static resource requests from IIS or separate?
We know that iis can only process static files. If you access dynamic files such as.aspx files, iis will hand them to aspnet_isapi to process the request, and then return the result to iis. As a static file processing, Nginx has advantages over iis. When processing static files, what we usually do is merge and compress js and css files, and open one or more separate second-level domain names to serve as image servers. Reduce the waiting process on the front end. Or hand over the photo service to Youpai, Qiniu, etc. for processing. I studied it and photographed it some time ago, and it provides interfaces for REST and Form Api, which can be easily integrated into the past. Moreover, providing CDN acceleration is cheaper than building a static file server yourself.
6. Balancing the load...
When there are not enough web servers, you need to deploy load balancing on the web server at this time. Of course, there are many ways to deploy load balancing. I have never deployed this thing before. It's hard to say. When a single web server cannot support business needs, load balancing is necessary.
summary
Therefore, except for the second point among the above 6 points, which I think is due to the author's insufficient understanding of the system, all others are supported. If there is a problem with the system, it is never a problem with the language, but a problem with the architecture. Of course, this is just a personal opinion. Maybe everything I know is wrong.
Author: Zhang Wei Source: beixiu.net/