DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

The Affinity Between Events, Streams and Serverless

原文链接

The key to event-first systems design is understanding that a series of events captures behavior. By persisting the streams in Kafka we then have a record of all system activity (a source of truth), and also a mechanism to drive reactions.

FaaS

FaaS is the ability to take a function and run it somewhere in the cloud; it’s the “compute” part of the serverless stack where you bring your own code.

The function contains a bespoke logic block. It is then called via some kind of registry like an API gateway, or it is scheduled or triggered by a cloud-related event (i.e., data written to Amazon S3).

There are many benefits to FaaS:

  • Lightweight
  • Decoupled
  • Scalable
  • Very cost efficient (pay per use)

They are processed in isolation to perform simple enrichment and filtering before passing to a storage layer or queue. If the system
needs to guarantee event ordering when writing to an output stream then, as previously discussed, concurrent FaaS execution will lead to corruption unless they are synchronously driven at the partition level.

主要针对stateless的stream,FaaS的优势就体现出来了

Caveat emptor: FaaS gives us an excellent solution where processing is atomic (stateless), reliable latency is not a concern (1–100 ms) and the order of processing is not important. Stateful processing is also suitable provided that it is against an external resource and stale data concerns are understood.

FaaS event-driven principles:

  1. In band but edge (stateless on the way in or out), i.e., map user GeoIP to a geocell
  2. In band, stateless and not latency sensitive
  3. In band and enriched against external resources, i.e., enrich a user’s address
  4. Out of band, but edge: This is FaaS processing on a known set of data in response to an event where there is no downstream stream processing. For example, you can perform large-scale analytic processing of all auction site bidders against “cars in 2018” (a non-event-streaming problem).
  5. Ad hoc requests, but not streaming: They tend to be historic. If a large set of data is to be processed, then it is likely to be batch oriented. Historic analytics include Monte Carlo simulation, raw number crunching of event data, etc.

尽量在一些对时间不敏感的位置,偶尔的请求,但不要持续性。。

Next

The CNCF Serverless Working Group (which Confluent participates in) is shaping how FaaS will look in the next couple of years. There is a grand plan that CloudEvents should be publishable, emit through multiple transports and clouds and be consumed by a destination function that is written in any language.(有关CloudEvents部分)