各位大神,小弟最近研究kafka,看了很多说kafka可能会丢失消息。
实在不太明白做日志系统,在什么场景下可以容忍消息的丢失。
比如做实时日志分析系统的话,那么就是说我所看到的日志信息中可能是不全的,如果出现异常日志看不到可能会影响问题的定位?
还有看到说分布式集群kafka的某一节点崩溃可能也会导致这一节点消息的丢失(这个看kafka与rabbitMQ做对比的时候说到的,rabbitMQ不会有这个问题)。
如果说kafka这么不靠谱,为啥这么多大公司都在使用呢?
回复内容:
各位大神,小弟最近研究kafka,看了很多说kafka可能会丢失消息。
实在不太明白做日志系统,在什么场景下可以容忍消息的丢失。
比如做实时日志分析系统的话,那么就是说我所看到的日志信息中可能是不全的,如果出现异常日志看不到可能会影响问题的定位?
还有看到说分布式集群kafka的某一节点崩溃可能也会导致这一节点消息的丢失(这个看kafka与rabbitMQ做对比的时候说到的,rabbitMQ不会有这个问题)。
如果说kafka这么不靠谱,为啥这么多大公司都在使用呢?
rabbitMQ怎么做的,我不知道。
kafka会丢消息主要集中在两个环节
消息落盘时机
消息落盘有异步刷新和同步刷新两种,明显异步刷新的可靠性要高很多。但在某些场景下追求性能而忽略可靠性,可以启用。
消息存储维护
持久化存储,这句话不是说来玩的。Oracle/MySQL做了这么久的存储,其中的灾难恢复工具等都非常完备并形成体系(出问题你能找到人并能解决问题)kafka的存储谁特么知道~工具又特么的少!
另外就是落盘的存储介质,如果不做raid,那么单盘存在损坏的可能;做了raid,则成本上升。如果做多集copy,则存在网络同步延时所带来的瞬间数据不一致。
小结:kafka你要做到完全不丢数据(在非大灾大难的情况下,比如机房被原子弹轰炸;或者raid被误操作弄错同步时间或者低格等),是完全可以的。代价就是丢失一定的性能。
所以kafka我一般用在业务允许少量数据丢失但整体吞吐量非常大的场景(比如日志采集),数据统计分析(却少几百条数据不会对亿万级的样本空间产生什么影响)。
kafka也可以用在两个可靠存储之间做数据同步,比如MySQL(写)->MySQL(度),因为MySQL(写)保证了数据可被重放,所以kafka出问题时恢复速度和恢复可靠程度是可以得到保证的。

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

TooptimizePHPapplicationsforperformance,usecaching,databaseoptimization,opcodecaching,andserverconfiguration.1)ImplementcachingwithAPCutoreducedatafetchtimes.2)Optimizedatabasesbyindexing,balancingreadandwriteoperations.3)EnableOPcachetoavoidrecompil

DependencyinjectioninPHPisadesignpatternthatenhancesflexibility,testability,andmaintainabilitybyprovidingexternaldependenciestoclasses.Itallowsforloosecoupling,easiertestingthroughmocking,andmodulardesign,butrequirescarefulstructuringtoavoidover-inje

PHP performance optimization can be achieved through the following steps: 1) use require_once or include_once on the top of the script to reduce the number of file loads; 2) use preprocessing statements and batch processing to reduce the number of database queries; 3) configure OPcache for opcode cache; 4) enable and configure PHP-FPM optimization process management; 5) use CDN to distribute static resources; 6) use Xdebug or Blackfire for code performance analysis; 7) select efficient data structures such as arrays; 8) write modular code for optimization execution.

OpcodecachingsignificantlyimprovesPHPperformancebycachingcompiledcode,reducingserverloadandresponsetimes.1)ItstorescompiledPHPcodeinmemory,bypassingparsingandcompiling.2)UseOPcachebysettingparametersinphp.ini,likememoryconsumptionandscriptlimits.3)Ad


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
