There are various approaches you can leverage to optimize your integration with SDL Machine Translation Cloud for speed. Each are described in more details below.
- Use Keep-Alive connection
- Store and reuse authentication token
- Use the translationMode parameter to express preference for Speed
- Use synchronous translation endpoint for input under 1,000 characters
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).
Declare translationMode preference for Speed
There is an optional parameter for the translation endpoints named translationMode that was made available as of v4.3.4. This parameter allows the integrator to specify a preference to the translation service to perform a "speed" or "quality" decoding if possible. Currently the translation service supports two translation modes: "speed" and "quality".
- In “quality mode”, our algorithms perform an extended statistical search, which sometimes results in a better quality output.
- “Speed mode” is instead optimized towards returning a translation as fast as possible.
This translationMode can be globally set on a per account basis (however, not available via the UI). Every translation in that account will translate using that setting, unless explicitly overridden from the API call. When this parameter is not used, the translation service automatically decide which mode to perform on each translation based on SDL proprietary heuristic.
Use synchronous translation endpoint
The synchronous translation endpoint is recommended for integration where there is absolute certainty that the input source is always no longer than 1,000 characters, or 200 words. As with any synchronous requests, the server does not respond until the action is complete. For use-cases where the input is certainly always short, the wait time for a sync response will most likely be more minimal compared to the polling for status process of an asynchronous request.
See the page on Synchronous translation for more details.
1 https://www.imperva.com/learn/performance/http-keep-alive/