Build temporal microservice

Hi all,
I’m new with Temporal,
I have a simple micro service with:

  • api/main.go (receive request and parsing data & execute new workflow)
  • worker/main.go
  • workflow.go
    On local, I need run: go run api/main.go (terminal tab 1) & go run worker/main.go (terminal tab 2) but I think it’s not a better way if I deployment in server, so how can I run all service with 1 CLI script ?
    Thanks all.

Temporal SDKs are composed of two different apis, your client apis and your workflow apis.
Client apis can be used by your users for example, apps that would need to request workflow execution, signal data to workflow executions, query data from executions, query visibility data, etc.
All communications between the client apis and your workers happen through the Temporal server.
So for example
c.ExecuteWorkflow is a grpc request that is sent to the temporal server frontend service. Server then creates the durable wf execution and communicates to your workers(s) by placing tasks on the task queues that the workers are listening on.

Your workers are processes that actually execute your workflow and activity code. Worker processes do not have to live on the same containers / pods as the client applications, and often its not recommended that they do. Workers are related to your application performance and often you want to deploy them on different envs than your client applications. In addition you want to have scalability and replication of your worker processes as this is important for things like fault tolerance and resilience (as workflow execs are not tied to a single worker so with lets say one worker pod being down your execs could continue on workers on another pod). Another important thing regarding performance is that given server and SDK metrics that you collect you might have to scale up your worker pods/containers (independently of your client apps) in order to be able to process peak loads and keep up demands of your performance needs.

So to answer your question, if you are looking at a simple test then you could just start the workers and then your client in a single process. For anything else would recommend deploying them separately. Hope this helps.

2 Likes

Thanks you so much,
I had a solution for my issue.