Skip to main content

Best practices

The performance of your services depends on how you build your node and data flow. Below are some best practices that you can utilize while designing your services.

  • Keep your services simple. The number of nodes that you use in your models adds extra complexity and may decrease the performance of your service. Each node execution adds additional time to overall service execution. For this reason, the simpler the service, the faster it will execute.
  • Watch out for infinite loops. If you are using loops in your services, pay extra attention to loop iteration conditions. Think about outlier cases and set your loop iteration or exit conditions carefully.
  • Offload time-consuming operations to message queues. If there are activities that can be offloaded from the main service, then move them to separate messaging services to improve the execution performance of the main service.
  • Pay special attention to the timing of node activations. Running a service corresponds to the sequential activation of the nodes and the data flow between nodes. Hence, the major concern in constructing the service running mechanism is the correct timing of node executions. If the timing of node executions is not properly set, you can get unexpected results.
  • Test your services before deploying them to production. Even though you made some minor changes to your existing services, it is always good to test them before deploying them to production.
  • Use transactions if you update multiple different model objects in a single service. If your service performs multiple database update operations in a single service, it is recommended that you use transactions to ensure data integrity in case of errors.
  • Avoid hard-coded values in service node properties. While setting the parameters of your nodes, prefer not to use hard-coded values; instead, use application params to manage all required variables centrally.
  • Pay attention to validation results. While building your service, Altogic automatically validates your service design and provides results on a node basis. A service can be executable only if it has no validation errors. For this reason, fix all validation errors before running your services.
  • Prevent the premature end of services using success and error response nodes. Each service in Altogic has a default Start node. However, it is up to the user how to end the execution of the service, either successfully or with errors. Altogic raises an error if no success or error response node is executed at the service execution end. For this reason, it is important that you use response nodes as the last step of your service designs.