Performance tip #2: Optimizing synchronizations

General Discussions
Best Practices
Examples

Performance tip #2: Optimizing synchronizations

Postby Christian Estrup » Mon Feb 15, 2010 1:04 pm

Quite a few integrations need to synchronize data to or from e-conomic. Here are some tips on best practices for typical scenarios:

Sending orders and/or invoices to e-conomic from e.g. a web shop
1. Use data classes – both for reading, creating and updating data.
2. If possible, queue your order/invoice creation instead of necessarily transferring data real-time. This will allow you to further exploit data class optimizations by utilizing the data array methods.

Updating a web shop with stock status from e-conomic
Relying on stock status transferred from e-conomic with some arbitrary interval can be somewhat risky – unless you transfer this with VERY short intervals, which may in turn give you a lot of API usage warnings.

A better approach would be a workflow like this:

1. Download the full product register – using GetDataArray() in batches of 500 or 1,000 products – every 2-4 hours.
2. Between updates, maintain local statistics of how many pieces of each product has been ordered or sold.
3. Calculate the current stock status from the last data transferred from e-conomic, adjusted for orders/invoices created since then.

Checking for new entries – including customer/supplier entries – or invoices
We’ve seen some developers implementing this by transferring ALL entries or invoices on EVERY transfer. This is completely unnecessary! Entries use a series of consecutive serial numbers, and expose the GetLastUsedSerialNumber() method. Thus, the fastest way to synchronize entries is to store the last used serial number, as well as any previously-transferred entries, locally – and then use the FindBySerialNumber(from, to) method to transfer only new entries.

Invoices also typically use a consecutive number series – thus allowing you to transfer only new invoices using the FindByNumber() method. There is one exception to this, though: If you need to know the Remainder or RemainderDefaultCurrency of invoices – since these can change over time, you’ll need to pull the full invoice register. In either case, use GetDataArray() in batches of 500 or 1,000 invoices.
Christian Estrup
Chief Architect

Image
Online accounting
User avatar
Christian Estrup
 
Posts: 70
Joined: Tue Jun 09, 2009 4:37 pm

Re: Performance tip #2: Optimizing synchronizations

Postby pwe » Wed Aug 04, 2010 2:54 pm

We’ve seen some developers implementing this by transferring ALL entries or invoices on EVERY transfer. This is completely unnecessary! Entries use a series of consecutive serial numbers, and expose the GetLastUsedSerialNumber() method. Thus, the fastest way to synchronize entries is to store the last used serial number, as well as any previously-transferred entries, locally – and then use the FindBySerialNumber(from, to) method to transfer only new entries.


We already do that. This gives a locally stored file lager than 1/4 MB locally with old entries for an account. Now, that may not sound as an exteme lot, but duplicating data shouldn't be the path to the future.

But I suppose we can live with it.

Best regards
pwe
pwe
 
Posts: 3
Joined: Wed Jan 27, 2010 6:13 am


Return to Miscellaneous



cron