Optimization Part 2 (Deep Save)

Hi

My first approach for optimization was move all the images outside Backendless but 140 pages later was not solve the main problem still peak’s that kill my business.

Yesterday I found 906 requests during a Saturday when the client not receiving visitors. I’m in the access control business.

How to check exactly what’s happened? I’m ready to start a 2nd optimization process but no idea how to identify the peak’s. Thanks Mario

Hi @Mario_Ghersi,

I can suggest that you start the new part of optimization by finding the most frequent API calls. You can find them on the Analytics → API calls tab. Filter the requests by the required time range and find out which requests are the most frequent to determine what triggers them.
Regards,
Marina

My principal data to registered is the visit of a person and for that I have this table that needs 7 relations API calls but the full process involves 19 API calls + some image downloads. aprox 25 calls. And each person should take 10 seconds to process.

Any way to add the 6 relations in only 1 API calls?
Thanks, Mario

Hi @Mario_Ghersi.

You should have a look at the Deep Save API, it can give you all those relations added in 1 API call. You can see how Mark goes through this in this video, and it really is not hard to implement/use. I quite prefer it in fact to how you are now setting the relations one by one, less code and just as easy to understand/read.

Ok I implement DeepSave it’s like magic very easy but looks like it’s the same quantity of API calls in the browser side:

DeepSave:
Screenshot 2023-06-29 at 18.12.04

No DeepSave:
Screenshot 2023-06-29 at 17.41.00

But I can’t complete the operation do to and error:
message:
“Deep save exception. Value for ONE_TO_ONE relation must be instance of Map or null. ‘java.lang.String’ was given instead.”

The payload looks like it’s correct:

  1. {fecha_ingreso: 1688074695445, noAutorizado: true, user: “5BF32C7F-4F7E-44BD-BCF7-0F14F345EFAE”,…}

  2. acceso_ingreso: “6F7EEE50-CF88-4479-86BC-98CB2989EE3F”

  3. autoriza_ingreso: “AE4F3C0B-08A8-45A3-86EF-CC05EEF95248”

  4. cliente: “D04002B7-2979-41C2-8004-D3C8E63217CB”

  5. destino_visita: “424C83E2-07FA-47DB-B503-7CCD61C32E54”

  6. fecha_ingreso: 1688074695445

  7. noAutorizado: true

  8. user: “5BF32C7F-4F7E-44BD-BCF7-0F14F345EFAE”

Any ideas?
Thanks, Mario

The problem was send the objectId and it’s necessary the full object for this case full fill the relation.

Now I don’t know how to calculate the “Transactions”, I’m using Cloud 9 and the only DeepSave is working just with only 1 relation. For 5 more transactions it’s 50 dollars but I had 6 relations to handle. Still to complicated to solve the optimization.

How to calculate the number of Transactions necessary for use DeepSave ?

Thanks, Mario

Hello, @Mario_Ghersi.

Yes, we can but calculation can be a little bit tricky.
In general for each create/update operation on the object we need 1 operation.
For relations optimizations were performed so when you store list of relations all new objects will be created in a batch using “bulk create”, each of existing objects will be updated using separate operation, and at the end additional operation will be used to bind new relations to the parent.
These are the main rules using which you can try to count amount of operations

Example:
Conditionally, if you store 1 object with 10 relations, including 5 new and 5 existing ones, a total of 8 operations will be used for the transaction (1 to delete the parent object, 1 to create 5 new ones, 5 to update 5 existing ones and 1 for establishing connections)

Regards, Nikita.