我的應用程序監聽kafka
話題並將數據轉儲到cassandra
。線程也從mongo
加載一些信息。 kafka
滯後題目增加。我已經看到,加載某些類時主要是線程被阻塞。下面附上我的thread_dump
。線程在加載Class時通過ClassUtils.java被阻止
"KafkaConsumer-49" prio=10 tid=0x00007f1178fdd000 nid=0x78e0 waiting for monitor entry [0x00007f1155fb5000]
java.lang.Thread.State: BLOCKED (on object monitor)
at java.lang.ClassLoader.loadClass(ClassLoader.java:403)
- waiting to lock <0x00000006c0655b58> (a java.lang.Object)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.data.convert.SimpleTypeInformationMapper.resolveTypeFrom(SimpleTypeInformationMapper.java:56)
at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:103)
at org.springframework.data.convert.DefaultTypeMapper.getDefaultedTypeToBeUsed(DefaultTypeMapper.java:144)
at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:121)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:186)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:176)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:172)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:75)
at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1840)
at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1536)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1336)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1322)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:495)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:486)
at com.snapdeal.coms.timemachine.mao.TimeMachineMao.getVendorProductsForUploadId(TimeMachineMao.java:32)
at com.snapdeal.coms.timemachine.service.TimeMachineService.getVendorProductsForUploadIdAndSupc(TimeMachineService.java:35)
at com.snapdeal.coms.timemachine.event.SupcUploadIdStateUpdateEventHandler.handleEvent(SupcUploadIdStateUpdateEventHandler.java:40)
KafkaConsumer-48" prio=10 tid=0x00007f1178fdb000 nid=0x78df waiting for monitor entry [0x00007f11560b6000]
java.lang.Thread.State: BLOCKED (on object monitor)
at java.lang.ClassLoader.loadClass(ClassLoader.java:403)
- waiting to lock <0x00000006c0655b58> (a java.lang.Object)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.data.convert.SimpleTypeInformationMapper.resolveTypeFrom(SimpleTypeInformationMapper.java:56)
at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:103)
at org.springframework.data.convert.DefaultTypeMapper.getDefaultedTypeToBeUsed(DefaultTypeMapper.java:144)
at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:121)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:186)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:176)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:172)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:75)
at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1840)
at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1536)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1336)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1322)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:495)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:486)
at com.snapdeal.coms.timemachine.mao.TimeMachineMao.getVendorProductsForUploadId(TimeMachineMao.java:32)
at com.snapdeal.coms.timemachine.service.TimeMachineService.getVendorProductsForUploadIdAndSupc(TimeMachineService.java:35)
at com.snapdeal.coms.timemachine.event.SupcUploadIdStateUpdateEventHandler.handleEvent(SupcUploadIdStateUpdateEventHandler.java:40)
at com.snapdeal.coms.timemachine.TimeMachine.onEvent(TimeMachine.java:109)
「KafkaConsumer-47」 PRIO = 10 TID = 0x00007f1178fd9800 NID = 0x78de等待監視器條目[0x00007f11561b7000] java.lang.Thread.State中:BLOCKED(對象監視器上) 在java.lang.ClassLoader中.loadClass(ClassLoader.java:403) - 等待鎖定< 0x00000006c0655b58>(java.lang.Object) at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader .loadClass(ClassLoader.java:356) at org.springframework.util.ClassUtils.forName(ClassUtils.java:258) at org.springframework.data.convert.SimpleTypeInfo在org.springframework.data.convert.DefaultTypeMapper.getDefaultedTypeToBeUsed(DefaultTypeMapper.java:144)上的rmationMapper.resolveTypeFrom(SimpleTypeInformationMapper.java:56) at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:103) 在org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:121) 在org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:186) 在org.springframework。 data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:176) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:172) at org.springframework.data。 mongodb.core.convert.MappingMongoConverter.read(Mappin gMongoConverter.java:75) at org.springframework.data.mongodb.core.MongoTemplate $ ReadDbObjectCallback.doWith(MongoTemplate.java:1840) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java: 1536) 在org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1336) 在org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1322) 在有機springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:495) 在org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:486)
"KafkaConsumer-46" prio=10 tid=0x00007f1178fd8000 nid=0x78dd waiting for monitor entry [0x00007f11562b8000]
java.lang.Thread.State:BLOCKED(在對象監視器上) at java.lang.ClassLoader.loadClass(ClassLoader.java:403) - 等待鎖定< 0x00000006c0655b58>(java.lang.Object) at sun .misc.Launcher $ AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at org.springframework.util.ClassUtils.forName(ClassUtils.java:258) org.springframework.data.convert.SimpleTypeInformationMapper.resolveTypeFrom(SimpleTypeInformationMapper.java:56) at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:103) at org.springframework.data.convert.DefaultTypeMapper .getDefaultedTypeToBeUsed(DefaultTypeMapper.java:144) 在org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:121) 在org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:186) 在org.springframework。 data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:176) at org.springframework.data.mongodb.core.convert。MappingMongoConverter.read(MappingMongoConverter.java:172) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:75) at org.springframework.data.mongodb.core.MongoTemplate $ ReadDbObjectCallback。 doGith(MongoTemplate.java:1840) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1536) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java: 1336) 在org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1322) 在org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:495) 在有機springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:486) at com。 snapdeal.coms.timemachine.mao.TimeMachineMao.getVendorProductsForUploadId(TimeMachineMao.java:32) at com.snapdeal.coms.timemachine.service.TimeMachineService.getVendorProductsForUploadIdAndSupc(TimeMachineService.java:35) at com.snapdeal.coms.timemachine。 event.SupcUploadIdStateUpdateEventHandler.handleEvent(SupcUploadIdStateUpdateEventHandler.java:40)
我不確定爲什麼所有線程都被阻塞。我以爲班級只能加載一次,之後不需要任何鎖定。
我已經檢查過。消費者抵消正在發生,但滯後正在增加。我已經創建了100個關於我的主題的截圖,目前正在運行50個消費者線程。在分析線程轉儲時,我看到大多數線程處於阻塞狀態。已經附加線程轉儲 –
'如果消費者偏移正在移動,但消費者滯後(日誌結束與消費者偏移之間的差異)正在增加,則消費者比生產者慢 - 從我可以算出的FAQ – user2720864
這就是爲什麼我增加了消費者線程數。但大多數線程在從類加載器中的mongo中檢索數據時處於阻塞狀態。我不明白爲什麼同班同學再次加載。 –