Summary: Helpful recommendations for tuning GigaSpaces, boosting its performance, and improving its scalability.
OverviewThis section lists helpful recommendations for tuning the GigaSpaces, boosting its performance, and improving its scalability. Design Your Space ClassPay attention to the size of your Entries – do you really need all this information in the space? The bigger your Entries, the longer it takes to move them around, store them to disk, and fetch them back. Consider replacing a heavyweight blob field with a simple string URL, and use it later for fetching on demand. Contact GigaSpaces support for an example of this pattern. If you are using user-defined classes for your Space Class fields, try efficiently implementing java.io.Externalizable with these classes. This will reduce the amount of data transferred over the network and written/read to/from the database, saving both time and space. Make proper use of indexesGigaSpaces includes a sophisticated built-in indexing module (regardless whether the space is persistent or not) that maintains index list data for each indexed Space Class attribute. If you keep a large number of Space objects from the same class in the space, consider defining one or more indexes for attributes used with template matching. Defining indexes will improve the read/take/clear operations response time significantly, up to ten to fifty times faster. Remember, indexes influence write/update operations response time, so choose your indexed fields carefully - each index has an overhead. GigaSpaces offers implicit indexing and explicit indexing. Blocking Take and Thread ConsumptionWhen performing blocking operations – read or take with timeout >0, it is recommended to set the operation timeout for short durations (5-30 seconds), and not to FOREVER. This allows the space's internal thread pool to balance the different requests without exhausting all pending operations thread pool. Use Batch OperationsBatch operations (writeMultiple, readMultiple, takeMultiple, updateMultiple) perform actions on groups of Entries in one call. Instead of paying a penalty for every entry (remote call, database access, ...) you pay it only once. Try to design your hot spots around batch operations - this can drastically improve your application performance, up to ten to fifty times faster. Use Transactions CautiouslyEach transaction has an overhead. Do not use read under a transaction if you do not have a very good reason to do so. Use non-transactional read instead. This reduces database access for persistent spaces and eliminates transaction locks. If you really need to do some operations inside a transaction, use batch operations with transactions. Query OptimizationsWhen using the or logical operation together with and operations as part of your query (JDBC , JavaSpaces with SQLQuery) you can speed up the query execution by having the and conditions added to each or condition. select uid,* from table where (A = 'X' or A = 'Y') and (B > '2000-10-1' and B < '2003-11-1') would be executed much faster when changing it to be: select uid,* from table where (A = 'X' and B > '2000-10-1' and B < '2003-11-1') or (A = 'Y' and B > '2000-10-1' and B < '2003-11-1') Use an Embedded Space if PossibleIf you access the space from a single JVM, or access it a large number of times from one JVM, use the embedded space mode. This eliminates the overhead of remote calls to the space. The slower your network compared to other resources (for example, a disk), the greater will be the noticeable improvement. Use Update Instead of Take and WriteIf you need to modify entry data, use update instead of take+ write. This saves you an extra call on the space. Distribute Data and User Requests among Several PartitionsA single machine is always limited in the amount of data and user requests it can handle. Memory Usage ConsiderationsHere are several guidelines to reduce the client and space server memory footprint:
Choose Local Transactions Over Distributed TransactionsDistributed Transactions perform a lengthy 2PC process. Local Transactions, in contrast, perform a 1PC process. If you are performing some operations under a transaction on a single space, use local transactions. The slower your network compared to other resources (for example, a disk), the greater will be the noticeable improvement.
Using Snapshot to Reduce Object Creation and Entry Data InspectionWhen using the same template for matching, consider using a snapshot template. A snapshot template is the result object of the JavaSpace.snapshot call. The returned result includes GigaSpaces internal representation of the template object that does not need to undergo any inspection before it is sent to the GigaSpaces server.
Determine Cache SizeWhen using persistent space and reusing data, you must take caching into account. The cache manager caches space objects for use and performs an LRU (Least Recent Use) based cleanup on the cache. When searching for a space object , the cache is searched first. Set the cache size to the number of Space objects that your environment can reasonably contain as resident in the VM heap size. This will prevent unnecessary queries on your database. If you want the cache size to be based on the JVM running the space you may use the memory usage options. Determine Database Connection PoolsWhen using persistent space and a large number of users/threads access the space concurrently, each of them requires a database connection. Set enough connections in the connection pool so that users won't be blocked. You should calculate the number of concurrent requests the space needs to handle based on the number of users that will access the space simultaneously. Benchmarking Your TuningThe Benchmark View provides a user interface for benchmarking the space.
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |