Skip to Content
JavaScript 经典实例:第三版
book

JavaScript 经典实例:第三版

by Adam D. Scott, Matthew MacDonald, Shelley Powers
September 2022
Intermediate to advanced
585 pages
8h 17m
Chinese
China Electric Power Press Ltd.
Content preview from JavaScript 经典实例:第三版
518
19
console.log('Running a job at midnight ');
}, {
scheduled:
true
,
timezone: "America/New_York"
});
scheduled
选项的值是一个布尔值,默认为
true
。如果设为
false
,则不运行定期
作业。
timezone
选项为日程指定时区。如果想查看全部时区名称,请访问
Moment.
js
的时区页面(
https://oreil.ly/VhAkl
)。
19.9
测试
WebSockets
应用的性能和功能
19.9.1
问题
你有一个应用频繁向连接的每个客户端发送更新信息,你担心应用的性能和负载。
19.9.2
方案
做速度(性能)测试和负载测试。详见下一节的讨论。
19.9.3
讨论
得益于
Node
WebSockets
,以及其他双向通信技术,在网页中不再需要使用计时
器访问服务器获取新数据,服务器可以直接把新数据推送给连接的所有客户端。例
17-4
演示的动画效果滚动时间线就是这种应用。
但是,问题也随之浮现:是的,效果很酷,但是这背后的代价呢?如果有
10
100
1000
10000
)个客户端连接,服务器会不会崩溃呢?所有客户端都能得到相同的
响应吗?两种测试可以回答这些问题。
速度(性能)测试:测试页面的加载速度,尤其是服务器承受一定压力时。
负载测试:模拟多个客户端同时访问页面。
有提供这两种测试的服务,如果是大型商业运营公司,对应用的可靠性和性能极为
管理
Node
519
看重,强烈建议你使用这类服务。有些服务,例如 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JavaScript Patterns

JavaScript Patterns

Stoyan Stefanov
JavaScript

JavaScript

David Flanagan
JavaScript

JavaScript

T. J. Crowder

Publisher Resources

ISBN: 9787519869601