Skip to Content
微服务与事件驱动架构
book

微服务与事件驱动架构

by Adam Bellemare
October 2021
Beginner to intermediate
250 pages
7h 11m
Chinese
Posts & Telecom Press
Content preview from 微服务与事件驱动架构
132
9
9.10
 调整函数
每个函数都有基于其工作量的具体需求。优化函数在执行期间使用的资源可以确保在保持
低成本的同时保持高性能。在建立资源和调整函数的参数时,有一些事情需要考虑。
9.10.1
 分配足够的资源
每个函数可以被分配一定量的
CPU
和内存资源。重要的是要根据函数需求来调整这些参
数:过度分配会使成本变高,过少分配则可能导致函数崩溃或耗时太久。
最大执行时间是另一个要考虑的因素,因为它限制了函数可能运行的时长。这个参数与批处
理的大小密切相关,因为函数处理事件的时间通常与要处理的事件数呈线性关系。将最大执
行时间设置为高于处理特定批量大小事件的最大预期时间,以避免不必要的函数超时错误。
最后,还必须考虑
FaaS
解决方案的界限上下文中对状态存储的所有外部
I/O
。函数的工作负
载随输入事件流的变化而变化,有些工作负载需要对外部状态进行持续的
I/O
操作
,而其他
工作负载只需要零星的
I/O
。未能提供足够的
I/O
资源会导致吞吐量和性能降低。
9.10.2
 批量事件处理的参数
如果函数无法在其执行时间期限内处理分配给它的批量事件,那么函数的执行就被认为是
失败的并且必须重新进行批处理。但是,除非调整分配给函数的执行时间或输入事件的批
量大小,否则处理很可能再次失败。因此,必须至少调整以下两项配置中的其中一项:
增加函数的最大执行时间;
减小函数要处理的事件的最大批处理大小。
自己建立到事件代理的连接并管理事件消费的函数,可以做到在执行期间定
期提交偏移量,以确保批处理的部分完结。当只是将一批待消费的事件传递 ...
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

监控运维实践:原则与策略

监控运维实践:原则与策略

Mike Julian
Kafka权威指南

Kafka权威指南

Neha Narkhede, Gwen Shapira, Todd Palino
Web容量规划之美

Web容量规划之美

Arun Kejariwal, John Allspaw

Publisher Resources

ISBN: 9787115571106