Hi This may be a dumb question.. Why does Flink jo...
# random
j
Hi This may be a dumb question.. Why does Flink job manager serialize map functions and send them to task manager? I may have understood the working wrong but basically job manager sends a job to task manager and task manager completes it and reports it back. So, job manager is probably serializing those map and other rich functions and sending them to task manager? If this is right why cant it just say run abc map function with xyz parallelism? Task manager will obviously have the code so it doesnt actually need it to be sent from job manager or maybe I am understanding all this wrong. Can someone clarify the internal working? Thank you
k
Your understanding is correct. In my understanding Taskmanagers actually don't have the code in Session Mode. Only in Application Mode the Taskmanagers already have the code. cc @Chesnay Schepler
c
The job manager doesn't send a job to the task manager; but tasks, a unit of work that the jobmanager splits the job into. The problem with your approach is that it would imply running the main method (to actually instantiate the function) on every TM, but this is often not possible because the job may rely on settings/arguments/environment variables that only exist on the client, or it queries external system etc etc.
The serialization additionally safeguards against certain user-mistakes, like trying to pass state from one function to another through a collection.
As for whether the TM has the code, in session mode the jars and serialized functions are submitted to the TM from the JM. In application mode the jars are already on the TM, and the serialized functions are sent later.
Your approach could however absolutely work; you'd just need to make sure that the job generation (including all parameters that are passed to functions) is 100% deterministic from the point the job is submitted to the cluster irrespective of which process is generating the job or when that happens.
j
Ok got it. Thank you so much for the detailed explanation!