  Fog computing can support IoT services with fast response time and low
bandwidth usage by moving computation from the cloud to edge devices. However,
existing fog computing frameworks have limited flexibility to support dynamic
service composition with a data-oriented approach. Function-as-a-Service (FaaS)
is a promising programming model for fog computing to enhance flexibility, but
the current event- or topic-based design of function triggering and the
separation of data management and function execution result in inefficiency for
data-intensive IoT services. To achieve both flexibility and efficiency, we
propose a data-centric programming model called Fog Function and also introduce
its underlying orchestration mechanism that leverages three types of contexts:
data context, system context, and usage context. Moreover, we showcase a
concrete use case for smart parking where Fog Function allows service
developers to easily model their service logic with reduced learning efforts
compared to a static service topology. Our performance evaluation results show
that the Fog Function can be scaled to hundreds of fog nodes. Fog Function can
improve system efficiency by saving 95% of the internal data traffic over cloud
function and it can reduce service latency by 30% over edge function.
