Understanding the memory model

Apache Ignite has a durable memory architecture for storing and accessing data and indexes. The memory architecture for in-memory and on-disk storage for native persistence is the same. The available memory is split into multiple pages (you can configure the page size) and are stored in off-heap (outside the Java heap) and on disk.

The durable memory can have multiple data regions and each data region can be configured separately to set the size, eviction policies, persistent flag and many other attributes. The following diagram depicts the durable memory architecture:

The basic components are as follows: 

  • Data regions: By default, Apache Ignite creates a single data region which can take upto 20% of available RAM. We can configure the durable memory size using the DataStorageConfiguration API. The following code snippet configures our durable memory to use 6 GB RAM, enables metrics, sets the page size of 2 KB (the default page size is 4 KB and you can set the page size value as minimum 1 KB and max 16 KB and the value should be power of 2—such as 1, 2, 4, 8 and 16), sets the minimum and maximum system region size, and finally sets two data region configs—soccerRegion and hockeyRegion (each region can be configured separately):
      IgniteConfiguration cfg = new IgniteConfiguration();

DataStorageConfiguration storageCfg = new
DataStorageConfiguration();
// set max size 6GB.
storageCfg.getDefaultDataRegionConfiguration().setMaxSize(6L * 1024
* 1024 * 1024);
storageCfg.setMetricsEnabled(true);
storageCfg.setPageSize(2 * 1024);
storageCfg.setSystemRegionInitialSize(50 * 1024 * 1024);
storageCfg.setSystemRegionMaxSize(100 * 1024 * 1024) ;
storageCfg.setDataRegionConfigurations(soccerRegion, hockeyRegion);
cfg.setDataStorageConfiguration(storageCfg);

Ignition.start(cfg);

  • Memory segments: A memory segment is a continuous array of physical memory bytes allocated by the OS, and each array element is a page of fixed size defined in DataStorageConfiguration. There four types of page—data, index, B+ tree, and free lists.
  • Data pages: A data page holds multiple key/value pairs. When a new entry is added to the page, Ignite checks for the best page to store the key/value pair. If the entry size exceeds the page size, it spans more than one data page. Each data page is divided into four parts—a header for page metadata, entries are stored right-to-left, the offsets (pointers to the entries inside a page) are stored left-to-right, and the middle of the page is kept free to let the offset and data (key/value) grow:

  • Index pages: Ignite keeps a dedicated B+ tree for each SQL index and cache keys. An index page stores the information to locate a value in data page, the offset value of data page, and links to other index pages to retrieve indexed values quickly.
  • B+ tree meta-pages: These store the root of a specific B+ tree and its layers for efficient execution of range queries. The B+ tree data structure is used for efficient data retrieval.
  • Free lists meta-pages: This is a doubly linked list data structure and stores references to free page groups. Index and data page groups are stored separately. Each group contains references to memory pages of approximately equal free space.

The following section will explain the internal workflow of durable memory management—how Ignite manages cache operations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.114.19