Apache Ignite 2.16.0启用持久化后的性能问题排查求助
Apache Ignite 2.16.0 持久化启用后性能问题排查与优化建议
问题背景
正在开展多种内存数据网格(IMDG)性能对比测试,发现Apache Ignite 2.16.0启用持久化后性能不达预期。测试用Key为约1KB的Java类,Value为1KB至数MB的字符串形式Blob的Java类。
客户端代码实现
客户端配置
ClientConfiguration cfg = new ClientConfiguration() .setAddresses(addresses) .setPartitionAwarenessEnabled(true); BinaryConfiguration binaryConfiguration = new BinaryConfiguration(); BinaryTypeConfiguration binaryTypeConfiguration = new BinaryTypeConfiguration("data.*"); binaryTypeConfiguration.setSerializer(new IgniteModelBinarySerializer()); cfg.setBinaryConfiguration(binaryConfiguration); try (IgniteClient igniteClient = Ignition.startClient(cfg)) { // 测试代码逻辑 }
putAll 测试代码
Map<TestKeyIgnite, TestValueIgnite> values = new HashMap<>(); // 填充测试数据 long begin = System.nanoTime(); cache.putAll(values); long end = System.nanoTime();
服务器端配置
使用./apache-ignite-2.16.0-bin/bin/ignite.sh启动集群,加载以下配置文件:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean class="org.apache.ignite.configuration.IgniteConfiguration"> <property name="workDirectory" value="<mymachine>/work"/> <property name="sqlConfiguration"> <bean class="org.apache.ignite.configuration.SqlConfiguration"> <property name="queryEnginesConfiguration"> <list> <bean class="org.apache.ignite.calcite.CalciteQueryEngineConfiguration"> <property name="default" value="true"/> </bean> </list> </property> </bean> </property> <property name="dataStorageConfiguration"> <bean class="org.apache.ignite.configuration.DataStorageConfiguration"> <property name="defaultDataRegionConfiguration"> <bean class="org.apache.ignite.configuration.DataRegionConfiguration"> <property name="metricsEnabled" value="true"/> <property name="persistenceEnabled" value="true"/> </bean> </property> <property name="metricsEnabled" value="true"/> </bean> </property> <property name="metricsLogFrequency" value="30000"/> <property name="gridLogger"> <bean class="org.apache.ignite.logger.log4j2.Log4J2Logger"> <constructor-arg type="java.lang.String" value="../config/ignite-log4j.xml"/> </bean> </property> <property name="cacheConfiguration"> <list> <bean class="org.apache.ignite.configuration.CacheConfiguration"> <property name="name" value="region0"/> <property name="cacheMode" value="PARTITIONED"/> <property name="backups" value="1"/> </bean> <!--其他缓存配置类似...--> </list> </property> </bean> </beans>
已尝试的优化措施
- 调整WAL模式为
LOG_ONLY - 修改WAL文件大小(64MB至512MB)
- 启用Direct IO模式(添加启动参数
-J-DIGNITE_DIRECT_IO_ENABLED=true) - 设置
IGNITE_USE_ASYNC_FILE_IO_FACTORY=false - 配置写入限流
以上调整均未带来明显性能改善。
排查方向与优化建议
1. 二进制序列化优化
- 检查自定义
IgniteModelBinarySerializer实现:确保序列化逻辑高效,避免冗余操作;对于Blob类型,直接使用字节数组存储而非字符串,减少序列化/反序列化开销。 - 启用Ignite二进制对象紧凑格式:设置
binaryTypeConfiguration.setCompactFooter(true),减少二进制元数据占用。
2. 数据存储与WAL优化
- 调整WAL刷盘策略:尝试设置
DataStorageConfiguration.setWalFlushFrequency(1000)(单位毫秒),平衡一致性与写入性能;或启用WAL_MODE_FSYNC仅在必要时刷盘(需评估数据一致性风险)。 - 分离WAL与数据目录:将WAL目录部署在独立物理磁盘,避免IO资源竞争。
- 调整数据页大小:默认页大小为4KB,针对数MB级大Value,尝试设置
DataRegionConfiguration.setPageSize(16384)或32768,减少页拆分次数。
3. 缓存配置优化
- 增大批量写入批次:设置
CacheConfiguration.setWriteBatchSize(1000)(根据单条数据大小调整),提升putAll的批量处理效率。 - 启用异步写入:非强一致性场景下,使用
cache.putAllAsync(values)异步写入,避免客户端等待刷盘完成。 - 提升缓存并发级别:设置
CacheConfiguration.setConcurrencyLevel(16)或更高值,增强多线程写入的并行度。
4. 系统层面优化
- 验证磁盘性能:用
fio等工具测试磁盘随机写/顺序写性能,确认磁盘是否成为瓶颈;持久化场景优先使用NVMe SSD。 - JVM参数调优:增加堆内存(如
-Xms32g -Xmx32g),确保热数据缓存充足;启用-XX:+UseG1GC垃圾收集器,减少GC停顿。 - 网络配置检查:确保客户端与集群节点带宽充足,避免跨机房部署的延迟;确认TCP_NODELAY参数已启用(Ignite默认开启)。
5. 性能监控与诊断
- 查看Ignite原生Metrics:通过
ignitevisorcmd.sh查看walWritingRate、checkpointingRate、diskWriteRate等指标,定位性能瓶颈点。 - 排查锁竞争:用JProfiler或AsyncProfiler分析节点线程状态,检查是否存在同步阻塞或锁等待。
内容的提问来源于stack exchange,提问作者adel orabi
相关产品推荐
相关产品推荐

