Use Keep-Alive
One of the most simple thing that you can do to improve your workflow with SDL Machine Translation Cloud is to use Keep-Alive in your calls.
"HTTP keep-alive, a.k.a., HTTP persistent connection, is an instruction that allows a single TCP connection to remain open for multiple HTTP requests/responses."1 - Imperva
Want to quantify how this can actually help your integration? Try the following.
- Create a new file called "connection-test.txt" and paste in this:
time_namelookup: %{time_namelookup}\n time_connect: %{time_connect}\n time_appconnect: %{time_appconnect}\n time_pretransfer: %{time_pretransfer}\n time_redirect: %{time_redirect}\n time_starttransfer: %{time_starttransfer}\n ----------\n time_total: %{time_total}\n
- Make a request to SDL MT Cloud REST API server (update the request sample below with your own credentials)
curl -w "@connection-test.txt" -XPOST -H "Content-type: application/json" \
-d '{"clientId": "F0ZUe28HFE8eaMLRLGJrIK0M6WGI9Nu", "clientSecret": "HFE8etNdtUP1liTrIKCtvlbGZ8Bv6Sxb-TAO_etNdHEcbWGu0KPGkVIu4QjiNEBt"}' \
"https://translate-api.sdlbeglobal.com/v4/token
"
-
Repeat step 2 - Because curl has keep-alive on as a default, you can compare the "time_connect" between the response for #2 and #3. The difference between these two values is approximately the time your program will save by making requests with keep-alive option enabled.
While at first glance, the time save may seem very minimal, but it is significant for any integrations that do many translation requests and polls per minute.
Store and reuse authentication tokens
All requests to the SDL MT Cloud REST API requires a valid authentication token. We recommend to request a token once and store it, then only request a new one when the token expires. This way you will get the best performance possible, as your application will not make an extra request for every translation call (this extra request will add up after a while if the application has high translation needs).
1 https://www.imperva.com/learn/performance/http-keep-alive/