用springMVC開發(fā)了一個在線考試系統(tǒng)。后臺用了Spring+SpringMvc,其他還用了SpringSecure。
除了服務器,其他客戶端載入一個頁面,看了下時間大約在70ms左右,不含載入后用post請求的一堆數(shù)據(jù)。重復刷新或者去其他頁面也都是要等70ms左右才能加載完頁面。頁面靜態(tài)資源緩存已開。
這個70ms左右的時間有辦法減少嗎?謝謝!
Each request takes 70 milliseconds, so 1 CPU core can only handle 1000/70=14 requests per second, and 4 CPU cores can only handle 56 requests. To be honest, it is already quite slow. Make another one In comparison, when using PHP7+OPcache to run WordPress on Ubuntu (i5-3230M), one CPU core processes one WordPress homepage request (no cache needs to be checked in the database), and it only takes 28 milliseconds. You must know that WordPress has poor performance. PHP program.
So, I think each request must take at least 10 milliseconds or less to be considered fast. After all, Nginx only takes 1 millisecond to display a directory list of the root directory of a website.
In fact, 70ms is not too slow for web applications.
If you think it affects the user experience, compare it with pure HttpServlet. There are many factors that affect page loading time. Long delays are not necessarily caused by Spring MVC, but are related to factors such as containers and browsers.
You still have to look at the code and the actual situation, if it is entirely because the response speed of that request is too slow. Generally, the best optimization for small systems is to add a cache to reduce database requests and fetch data directly from memory. This will be much faster!
This is mainly related to Spring’s view rendering mechanism. You can refer to: http://www.cnblogs.com/davidw...
Let’s put it this way, it may be fast to write simple pages directly using Servlet, but when you finish all the functions yourself, you may find that it is not even as fast as SpringMVC, and many of the functions you do are actually SpringMVC Wait until the framework already exists.
70ms
It’s still relatively fast, as this amount of time is completely insensitive to the user.
Separate the front-end and back-end, and then cache the GET request. Of course 70ms is already very fast.