Tutorial: Large Data Sources and Instant Feedback with Server Mode
- 4 minutes to read
This walkthrough is a transcript of the Large Data Sources and Instant Feedback with Server Mode video available on the DevExpress YouTube Channel.
The tutorial first describes the disadvantages of the standard data binding mode when handling very large data sources. You will learn how to use Server Mode data binding to address initial data loading and data manipulation performance. Finally, the walkthrough will demonstrate the Instant Feedback data binding mode that ensures that your application’s UI never freezes by performing data-related operations in a background thread.
In the sample application, the grid is bound to a data source with 100,000 rows using the default data binding mode. In this mode, the grid will load all data into the memory and will then manipulate this data in response to end-user action.
Run the app to analyze the grid’s performance. The grid will load all the records into memory, meaning increased memory consumption and delayed application startup. You can already see startup takes a very long time. As you can see in the task manager, the app is actually running and already consumes about 220 megabytes of memory.
To check the application status, click Break All. As you can see, the data source is still being populated. Click Continue and wait. After the application has finally started, 100000 records are displayed.
Data operations will all be performed by the grid control on the client machine. So the performance will depend on the client computer. You can see that even on a fast computer data grouping and sorting are performed with noticeable lags.
Now close the application and switch to the Server Mode data binding to improve the application’s performance. In this data binding mode, the grid control will request only a portion of data that is to be displayed on screen. Data shaping operations will be carried out by the server.
Remove the code and the BindingSource component that were previously added by Data Source Configuration Wizard. Then, invoke the grid control’s smart tag and click the Data Source Wizard link.
Choose the Entity Framework technology and select the existing data connection.
On the next page, select Server-Side Data Processing and click Next.
Finally, select the desired table, key expression and default sorting.
Now launch the app to see the result. Remember that in Server Mode, the grid will only request a few records to be displayed on screen, which means reduced memory consumption and faster application startup. This time, the application started in a few seconds. At the same time, you are able to access all 100,000 records. Scroll the View to see that there are practically no lags.
Grouping and sorting and filtering also work quickly. Data operations work fast, because after each end-user action, the grid sends a request for updated data to the server. The server will usually execute these operations much faster and then only a few visible records are returned to the grid. This mean that you have access to all records and are free to apply any data shaping operations you want.
If you check the Task Manager, you’ll see that memory consumption is reduced greatly compared to the standard mode.
Close the application to try one more data binding mode designed to handle large data sources.
Instant Feedback Mode
The currently applied data binding mode is synchronous. This means that the user interface freezes momentarily while the grid waits for updated data from the server. The DevExpress Grid Control also provides an asynchronous server mode, also known as Instant Feedback mode. It is the same as the Server Mode except it reloads data in a background thread to make sure your application’s UI doesn’t freeze.
Invoke the Data Source Wizard once again. This time, choose Asynchronous Server-Side Data Processing to enable the Instant Feedback mode. Then select the desired table, key expression and default sorting again.
Launch the app to see the changes. Notice that the grid doesn’t freeze while scrolling, grouping and sorting data. The loading indicator is displayed in the top-left corner while the data is retrieved in a background thread.
Supported Data Access Technologies
Note that the Entity Framework is not the only technology that supports these data binding modes. In the Visual Studio Toolbox, you can see the data source components that are used in Server Mode and Instant Feedback Mode for various data access technologies - Entity Framework, LINQ to SQL, Parallel LINQ to Objects or WCF Data Services.
You can add these components from the toolbox and bind the data manually instead of using the Wizard. Refer to product documentation to learn more (Large Data Sources: Server and Instant Feedback Modes).