{"id":393877,"date":"2024-06-29T11:16:47","date_gmt":"2024-06-29T11:16:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=393877"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=393877","title":{"rendered":"<span>PVbase: compacted topic \u0432 Apache Kafka<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Big Data, \u0438 \u0437\u0430\u0434\u0430\u0439\u0442\u0435 \u0441\u0435\u0431\u0435 \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0432 100 000 \u0440\u0430\u0437?\u00bb\u00a0\u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442: producer \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/577\/2e3\/547\/5772e354741eb8b5ebd8b179be3ab99b.jpg\" width=\"1200\" height=\"630\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/577\/2e3\/547\/5772e354741eb8b5ebd8b179be3ab99b.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>Log Compaction (\u0441\u0436\u0430\u0442\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0430) \u2013 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0432 Apache Kafka \u2013 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u043c \u0431\u0440\u043e\u043a\u0435\u0440\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c \u0434\u043b\u044f \u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0441 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0439\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0441\u0431\u043e\u0440\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 Kafka, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0431\u044a\u0451\u043c\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u0440\u0430\u0431\u043e\u0442\u044b compacted topic. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c log compaction, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043b\u044f \u0432\u0430\u0441.<\/p>\n<p>\u0421\u0443\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0442\u0430\u043a\u0443\u044e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u044e \u0438\u0437 \u0436\u0438\u0437\u043d\u0438: \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0435\u043a\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a (\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447) \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430 \u0433\u0440\u0430\u0434\u0443\u0441\u043d\u0438\u043a \u0438 \u0432\u043d\u043e\u0441\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b (\u0432 \u0440\u0430\u0437\u0434\u0435\u043b \u00ab\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0432\u043e\u0437\u0434\u0443\u0445\u0430\u00bb): <\/p>\n<blockquote>\n<p><em>\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/em><\/p>\n<p><em>+8 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/em><\/p>\n<p><em>2 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 14:40<\/em><\/p>\n<p><em>\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/em><\/p>\n<p><em>+9 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/em><\/p>\n<p><em>3 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 10:10<\/em><\/p>\n<p><em>\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/em><\/p>\n<p><em>+10 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/em><\/p>\n<p><em>4 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 15:30<\/em><\/p>\n<\/blockquote>\n<p>\u0414\u0440\u0443\u0433\u0438\u0435 \u043b\u044e\u0434\u0438 \u0441 \u043d\u0435\u043a\u043e\u0439 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043c\u043e\u0442\u0440\u044f\u0442 \u044d\u0442\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0438\u0445 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0438\u0447\u0451\u043c \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430, \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u043c \u0434\u043d\u044f\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u044e\u0442.<\/p>\n<p>\u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0443\u0440\u043d\u0430\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0412\u0430\u0441\u0438\u043b\u0438\u0439 \u041f\u0435\u0442\u0440\u043e\u0432\u0438\u0447 \u0438 \u0447\u0438\u0441\u0442\u0438\u0442 \u0435\u0433\u043e, \u0443\u0434\u0430\u043b\u044f\u044f \u0432\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0442\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0437\u0430\u043f\u0438\u0441\u044c (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0441\u043c\u044b\u0441\u043b\u0430): <\/p>\n<blockquote>\n<p><em>\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/em><\/p>\n<p><em>+10 \u00b0C<\/em><\/p>\n<p><em>4 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 15:30<\/em><\/p>\n<\/blockquote>\n<p><strong>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043f\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Kafka:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041a\u043b\u044e\u0447 (key): \u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447;<\/p>\n<\/li>\n<li>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (value): +10 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (timestamp): 4 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 15:30; <\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u043f\u0438\u043a (topic): \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c [4] \u2013 \u0440\u0430\u0437\u0434\u0435\u043b \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u00ab\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0432\u043e\u0437\u0434\u0443\u0445\u0430\u00bb;<\/p>\n<\/li>\n<li>\n<p> \u0420\u0430\u0437\u0434\u0435\u043b (partition): \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0442\u043e\u043f\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u0445 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f [4];<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u043d\u0430\u044f \u0432\u0441\u0451 \u044d\u0442\u043e, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0442 \u0418\u0432\u0430\u043d\u0430 \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435:<\/p>\n<p>\u00a0<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td colspan=\"5\">\n<p align=\"center\"><strong>\u0416\u0423\u0420\u041d\u0410\u041b   \u0421\u041e\u041e\u0411\u0429\u0415\u041d\u0418\u0419<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"4\">\n<p align=\"center\"><strong>\u0422\u043e\u043f\u0438\u043a   (topic):   <\/strong>\u0440\u0430\u0437\u0434\u0435\u043b \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u00ab\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0432\u043e\u0437\u0434\u0443\u0445\u0430\u00bb<\/p>\n<\/td>\n<td>\n<p>\u00a0<\/p>\n<\/td>\n<td colspan=\"3\">\n<p><strong>\u0420\u0430\u0437\u0434\u0435\u043b   (partition)<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u041a\u043b\u044e\u0447   (key)<\/strong><\/p>\n<\/td>\n<td>\n<p>\u0418\u0432\u0430\u043d   \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/p>\n<\/td>\n<td>\n<p>\u0418\u0432\u0430\u043d   \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/p>\n<\/td>\n<td>\n<p>\u0418\u0432\u0430\u043d   \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435   (value)<\/strong><\/p>\n<\/td>\n<td>\n<p>+8   \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/p>\n<\/td>\n<td>\n<p>+9   \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/p>\n<\/td>\n<td>\n<p>+10   \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u041c\u0435\u0442\u043a\u0430   \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (timestamp)<\/strong><\/p>\n<\/td>\n<td>\n<p>2   \u043d\u043e\u044f\u0431\u0440\u044f 2021, 14:40<\/p>\n<\/td>\n<td>\n<p>3   \u043d\u043e\u044f\u0431\u0440\u044f 2021, 10:10<\/p>\n<\/td>\n<td>\n<p>4   \u043d\u043e\u044f\u0431\u0440\u044f 2021, 15:30<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>C\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f Log Compaction \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e Kafka \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0435 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0442\u043e\u043f\u0438\u043a\u0430.\u00a0\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u043a\u0430\u043a \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u0434\u043e \u0441\u0431\u043e\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043a\u0435\u0448\u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0\u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, Apache Kafka \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043a\u043b\u044e\u0447\u043e\u043c.<\/p>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 Kafka \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u043c (consumer-\u0430\u043c) \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0437 \u0437\u0430\u043f\u0438\u0441\u0438 compacted topic.\u00a0\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445.\u00a0\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 (offset) \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f.\u00a0\u0416\u0443\u0440\u043d\u0430\u043b \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0433\u043e\u043b\u043e\u0432\u044b (head) \u0438 \u0445\u0432\u043e\u0441\u0442\u0430 (tail).\u00a0\u041a\u0430\u0436\u0434\u043e\u0435 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0435\u0446 head.\u00a0\u0412\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 log compaction \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0445\u0432\u043e\u0441\u0442\u0435 \u0443\u043f\u043b\u043e\u0442\u043d\u0451\u043d\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/340\/ac5\/cab\/340ac5cabe7c789328f9f0dae0f93fb3.png\" alt=\"\u0420\u0438\u0441. 1. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Kafka \u2013 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432\" title=\"\u0420\u0438\u0441. 1. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Kafka \u2013 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432\" width=\"665\" height=\"209\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/340\/ac5\/cab\/340ac5cabe7c789328f9f0dae0f93fb3.png\"\/><figcaption>\u0420\u0438\u0441. 1. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Kafka \u2013 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432<\/figcaption><\/figure>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u043e\u043f\u0438\u043a\u0430\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445:<\/p>\n<ul>\n<li>\n<p><strong><em>cleanup.policy=delete<\/em><\/strong>\u00a0\u2013 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445      \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p><strong><em>retention.bytes<\/em><\/strong>\u00a0\u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438,      \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p><strong><em>retention.ms<\/em><\/strong>\u00a0\u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439      \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412\u0430\u0436\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u0441\u0435 \u0443\u043f\u0443\u0441\u043a\u0430\u044e\u0442! \u0411\u0440\u043e\u043a\u0435\u0440 Kafka \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0445. \u041e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c retention policy. <\/p>\n<\/blockquote>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <em>cleanup.policy=compact<\/em>, \u0442\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0431\u0443\u0434\u0435\u0442 compacted topic. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u0430\u0436\u043d\u044b\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u044b:<\/p>\n<ul>\n<li>\n<p><strong>LogCleaner<\/strong> \u2013 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0442 \u0441\u0436\u0430\u0442\u0438\u0435 \u043b\u043e\u0433\u0430;<\/p>\n<\/li>\n<li>\n<p><strong>LogTail<\/strong> \u2013 \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0430, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0441\u0436\u0430\u0442\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p><strong>LogHead<\/strong> \u2013 \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0430, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0441\u0436\u0430\u0442\u0438\u044f \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ol>\n<li>\n<p><strong>LogCleaner<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043b\u043e\u0433 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c <strong>logHead<\/strong>\/<strong>logTail<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 offset&#8217;\u044b \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0432 <strong>logHead<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0441\u0430\u043c\u044b\u0439 \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442, \u0443\u0434\u0430\u043b\u044f\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043b\u044e\u0447\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u043b\u043e\u0433\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u043d\u0430 \u0441\u0436\u0430\u0442\u044b\u0439. <\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0430\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <strong>logCleaner<\/strong>:<\/p>\n<ul>\n<li>\n<p><em>log.cleanup.policy=compact<\/em> \u2013 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 <strong>log compaction<\/strong>;<\/p>\n<\/li>\n<li>\n<p><em>log.cleaner.max.compaction.lag.ms<\/em> \u2013 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043b\u044e\u0447 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u043b\u043e\u0433\u0443;<\/p>\n<\/li>\n<li>\n<p><em>log.cleaner.threads<\/em> \u2013 \u043a\u043e\u043b-\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 logCleaner.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043a\u043b\u044e\u0447\u0438 \u0441 \u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p><strong>\u0414\u0435\u0442\u0430\u043b\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b<\/strong><\/p>\n<p>Log compaction \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e Kafka \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0442\u043e\u043f\u0438\u0138\u0430. \u042d\u0442\u043e\u0442 \u0138\u0435\u0439\u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 key-value-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<br \/> \u0412 <a href=\"https:\/\/kafka.apache.org\/documentation\/#compaction\">\u0434\u043e\u0138\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <\/a>\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440 <em>user_id<\/em> -> <em>email<\/em>.<\/p>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u043e\u043f\u0438\u0138\u0430\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445:<\/p>\n<ul>\n<li>\n<p><em>cleanup.policy=delete<\/em> \u2013 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p><em>retention.bytes<\/em> \u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u0430, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p><em>retention.ms<\/em> \u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0436\u0438\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0138\u0430\u0138 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 log compaction.<\/p>\n<p>\u0421\u0138\u0430\u0447\u0430\u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e <a href=\"https:\/\/kafka.apache.org\/downloads\">Apache<\/a> <a href=\"https:\/\/kafka.apache.org\/downloads\">Kafka<\/a> (\u0432 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 2.7.0), \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c zookeeper \u0438 \u0431\u0440\u043e\u0138\u0435\u0440\u0430 \u0441 default-\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u0138\u0430\u043c\u0438:<\/p>\n<pre><code>.\/bin\/zookeeper-server-start.sh .\/config\/zookeeper.properties .\/bin\/kafka-server-start.sh .\/config\/server.propertie<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u043e\u043f\u0438\u0138:<\/p>\n<pre><code>.\/bin\/kafka-topics.sh \\ --bootstrap-server localhost:9092\\   --create \\ --topic test \u2013 topic-1 \\   --config \"segment.bytes=1024\" \\   --config \"cleanup.policy=compact\" \\   --config \"cleaner.max.compaction.lag.ms =60000\"<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c consumer&#8217;a:<\/p>\n<pre><code>.\/bin\/kafka-console-consumer.sh \\   --bootstrap-server localhost:9092 \\   --property \"print.key=true\" \\   --property \"key.separator=    \" \\   --from-beginning \\   --topic test topic-1<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c producer&#8217;\u0430:<\/p>\n<pre><code>.\/bin\/kafka-console-producer.sh \\   --bootstrap-server localhost:9092 \\   --property \"parse.key=true\" \\   --property \"key.separator=:\" \\   --topic test topic-1<\/code><\/pre>\n<p>\u0412 \u043e\u0138\u043d\u0435 producer&#8217;\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>> a:1 > b:1 > c:1 > a:2<\/code><\/pre>\n<p>\u0412 \u043e\u0138\u043d\u0435 consumer&#8217;a \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u0432\u0441\u0435 \u0442\u0435 \u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0435\u0440\u0435\u0437 60\u201390 \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 consoleconsumer, \u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435:<\/p>\n<pre><code>b   1 c   1 a   2<\/code><\/pre>\n<p>\u0421\u0436\u0430\u0442\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0426\u041f \u0432\u0430\u0448\u0438\u0445 \u0431\u0440\u043e\u043a\u0435\u0440\u043e\u0432.\u00a0\u0414\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u043d\u0443\u0436\u043d\u0430 \u043a\u0430\u043a \u043a\u0443\u0447\u0430 (\u043f\u0430\u043c\u044f\u0442\u044c), \u0442\u0430\u043a \u0438 \u0446\u0438\u043a\u043b\u044b \u0426\u041f \u043d\u0430 \u0431\u0440\u043e\u043a\u0435\u0440\u0430\u0445, \u0430 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u0442 \u0431\u0440\u043e\u043a\u0435\u0440\u043e\u0432 \u0440\u0438\u0441\u043a\u0443 \u0438\u0437-\u0437\u0430 \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u043e\u0441\u0442\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c\u00a0<strong><em>log.cleaner.dedupe.buffer.size<\/em><\/strong>\u00a0\u0438\u00a0<strong><em>log.cleaner.threads<\/em><\/strong>\u00a0\u043d\u0430 \u0441\u0432\u043e\u0438\u0445\u00a0\u0431\u0440\u043e\u043a\u0435\u0440\u0430\u0445, \u043d\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0443\u0447\u0438. \u0415\u0441\u043b\u0438 \u0431\u0440\u043e\u043a\u0435\u0440 \u0432\u044b\u0434\u0430\u0441\u0442\u00a0\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u00a0OutOfMemoryError, \u043e\u043d \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u0430 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0447\u0438\u0449\u0430\u0435\u043c\u044b\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u0442\u0435\u043c\u044b, \u0442\u0430\u043a \u0438 \u043e\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u043b\u044e\u0447\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u044d\u0442\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445.<\/p>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u2013 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 compacted topic&#8217;\u0430. <\/p>\n<p>\u0410\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438: <a href=\"https:\/\/habr.com\/ru\/users\/arsen_gl\/\">\u0410\u0440\u0441\u0435\u043d\u0438\u0439 \u0413\u043e\u043b\u0443\u0448\u043a\u043e\u0432<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438:<\/summary>\n<div class=\"spoiler__content\">\n<p><em>1.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"https:\/\/medium.com\/swlh\/introduction-to-topic-log-compaction-in-apache-kafka-3e4d4afd2262\"><em>https:\/\/medium.com\/swlh\/introduction-to-topic-log-compaction-in-apache-kafka-3e4d4afd2262<\/em><\/a><\/p>\n<p><em>2.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"https:\/\/towardsdatascience.com\/log-compacted-topics-in-apache-kafka-b1aa1e4665a7\"><em>https:\/\/towardsdatascience.com\/log-compacted-topics-in-apache-kafka-b1aa1e4665a7<\/em><\/a><em> <\/em><\/p>\n<p><em>3.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"http:\/\/cloudurable.com\/blog\/kafka-architecture-log-compaction\/index.html\"><em>http:\/\/cloudurable.com\/blog\/kafka-architecture-log-compaction\/index.html<\/em><\/a><em> <\/em><\/p>\n<p><em>4.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"https:\/\/kafka.apache.org\/documentation\/#intro_concepts_and_terms\"><em>https:\/\/kafka.apache.org\/documentation\/#intro_concepts_and_terms<\/em><\/a><em> <\/em><\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/590045\/\"> https:\/\/habr.com\/ru\/articles\/590045\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Big Data, \u0438 \u0437\u0430\u0434\u0430\u0439\u0442\u0435 \u0441\u0435\u0431\u0435 \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0432 100 000 \u0440\u0430\u0437?\u00bb\u00a0\u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442: producer \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>Log Compaction (\u0441\u0436\u0430\u0442\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0430) \u2013 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0432 Apache Kafka \u2013 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u043c \u0431\u0440\u043e\u043a\u0435\u0440\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c \u0434\u043b\u044f \u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0441 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0439\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0441\u0431\u043e\u0440\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 Kafka, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0431\u044a\u0451\u043c\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u0440\u0430\u0431\u043e\u0442\u044b compacted topic. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c log compaction, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043b\u044f \u0432\u0430\u0441.<\/p>\n<p>\u0421\u0443\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0442\u0430\u043a\u0443\u044e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u044e \u0438\u0437 \u0436\u0438\u0437\u043d\u0438: \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0435\u043a\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a (\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447) \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430 \u0433\u0440\u0430\u0434\u0443\u0441\u043d\u0438\u043a \u0438 \u0432\u043d\u043e\u0441\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b (\u0432 \u0440\u0430\u0437\u0434\u0435\u043b \u00ab\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0432\u043e\u0437\u0434\u0443\u0445\u0430\u00bb): <\/p>\n<blockquote>\n<p><em>\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/em><\/p>\n<p><em>+8 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/em><\/p>\n<p><em>2 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 14:40<\/em><\/p>\n<p><em>\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/em><\/p>\n<p><em>+9 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/em><\/p>\n<p><em>3 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 10:10<\/em><\/p>\n<p><em>\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/em><\/p>\n<p><em>+10 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/em><\/p>\n<p><em>4 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 15:30<\/em><\/p>\n<\/blockquote>\n<p>\u0414\u0440\u0443\u0433\u0438\u0435 \u043b\u044e\u0434\u0438 \u0441 \u043d\u0435\u043a\u043e\u0439 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043c\u043e\u0442\u0440\u044f\u0442 \u044d\u0442\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0438\u0445 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0438\u0447\u0451\u043c \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430, \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u043c \u0434\u043d\u044f\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u044e\u0442.<\/p>\n<p>\u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0443\u0440\u043d\u0430\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0412\u0430\u0441\u0438\u043b\u0438\u0439 \u041f\u0435\u0442\u0440\u043e\u0432\u0438\u0447 \u0438 \u0447\u0438\u0441\u0442\u0438\u0442 \u0435\u0433\u043e, \u0443\u0434\u0430\u043b\u044f\u044f \u0432\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0442\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0437\u0430\u043f\u0438\u0441\u044c (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0441\u043c\u044b\u0441\u043b\u0430): <\/p>\n<blockquote>\n<p><em>\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/em><\/p>\n<p><em>+10 \u00b0C<\/em><\/p>\n<p><em>4 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 15:30<\/em><\/p>\n<\/blockquote>\n<p><strong>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043f\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Kafka:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041a\u043b\u044e\u0447 (key): \u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447;<\/p>\n<\/li>\n<li>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (value): +10 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (timestamp): 4 \u043d\u043e\u044f\u0431\u0440\u044f 2021, 15:30; <\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u043f\u0438\u043a (topic): \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c [4] \u2013 \u0440\u0430\u0437\u0434\u0435\u043b \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u00ab\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0432\u043e\u0437\u0434\u0443\u0445\u0430\u00bb;<\/p>\n<\/li>\n<li>\n<p> \u0420\u0430\u0437\u0434\u0435\u043b (partition): \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0442\u043e\u043f\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u0445 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f [4];<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u043d\u0430\u044f \u0432\u0441\u0451 \u044d\u0442\u043e, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0442 \u0418\u0432\u0430\u043d\u0430 \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435:<\/p>\n<p>\u00a0<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td colspan=\"5\">\n<p align=\"center\"><strong>\u0416\u0423\u0420\u041d\u0410\u041b   \u0421\u041e\u041e\u0411\u0429\u0415\u041d\u0418\u0419<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"4\">\n<p align=\"center\"><strong>\u0422\u043e\u043f\u0438\u043a   (topic):   <\/strong>\u0440\u0430\u0437\u0434\u0435\u043b \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u00ab\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0432\u043e\u0437\u0434\u0443\u0445\u0430\u00bb<\/p>\n<\/td>\n<td>\n<p>\u00a0<\/p>\n<\/td>\n<td colspan=\"3\">\n<p><strong>\u0420\u0430\u0437\u0434\u0435\u043b   (partition)<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u041a\u043b\u044e\u0447   (key)<\/strong><\/p>\n<\/td>\n<td>\n<p>\u0418\u0432\u0430\u043d   \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/p>\n<\/td>\n<td>\n<p>\u0418\u0432\u0430\u043d   \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/p>\n<\/td>\n<td>\n<p>\u0418\u0432\u0430\u043d   \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435   (value)<\/strong><\/p>\n<\/td>\n<td>\n<p>+8   \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/p>\n<\/td>\n<td>\n<p>+9   \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/p>\n<\/td>\n<td>\n<p>+10   \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><strong>\u041c\u0435\u0442\u043a\u0430   \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (timestamp)<\/strong><\/p>\n<\/td>\n<td>\n<p>2   \u043d\u043e\u044f\u0431\u0440\u044f 2021, 14:40<\/p>\n<\/td>\n<td>\n<p>3   \u043d\u043e\u044f\u0431\u0440\u044f 2021, 10:10<\/p>\n<\/td>\n<td>\n<p>4   \u043d\u043e\u044f\u0431\u0440\u044f 2021, 15:30<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>C\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f Log Compaction \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e Kafka \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0435 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0442\u043e\u043f\u0438\u043a\u0430.\u00a0\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u043a\u0430\u043a \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u0434\u043e \u0441\u0431\u043e\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043a\u0435\u0448\u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0\u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, Apache Kafka \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043a\u043b\u044e\u0447\u043e\u043c.<\/p>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 Kafka \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u043c (consumer-\u0430\u043c) \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0437 \u0437\u0430\u043f\u0438\u0441\u0438 compacted topic.\u00a0\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445.\u00a0\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 (offset) \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f.\u00a0\u0416\u0443\u0440\u043d\u0430\u043b \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0433\u043e\u043b\u043e\u0432\u044b (head) \u0438 \u0445\u0432\u043e\u0441\u0442\u0430 (tail).\u00a0\u041a\u0430\u0436\u0434\u043e\u0435 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0435\u0446 head.\u00a0\u0412\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 log compaction \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0445\u0432\u043e\u0441\u0442\u0435 \u0443\u043f\u043b\u043e\u0442\u043d\u0451\u043d\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430.<\/p>\n<figure class=\"full-width\"><figcaption>\u0420\u0438\u0441. 1. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Kafka \u2013 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432<\/figcaption><\/figure>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u043e\u043f\u0438\u043a\u0430\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445:<\/p>\n<ul>\n<li>\n<p><strong><em>cleanup.policy=delete<\/em><\/strong>\u00a0\u2013 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445      \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p><strong><em>retention.bytes<\/em><\/strong>\u00a0\u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438,      \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p><strong><em>retention.ms<\/em><\/strong>\u00a0\u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439      \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412\u0430\u0436\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u0441\u0435 \u0443\u043f\u0443\u0441\u043a\u0430\u044e\u0442! \u0411\u0440\u043e\u043a\u0435\u0440 Kafka \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0445. \u041e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c retention policy. <\/p>\n<\/blockquote>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <em>cleanup.policy=compact<\/em>, \u0442\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0431\u0443\u0434\u0435\u0442 compacted topic. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u0430\u0436\u043d\u044b\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u044b:<\/p>\n<ul>\n<li>\n<p><strong>LogCleaner<\/strong> \u2013 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0442 \u0441\u0436\u0430\u0442\u0438\u0435 \u043b\u043e\u0433\u0430;<\/p>\n<\/li>\n<li>\n<p><strong>LogTail<\/strong> \u2013 \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0430, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0441\u0436\u0430\u0442\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p><strong>LogHead<\/strong> \u2013 \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0430, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0441\u0436\u0430\u0442\u0438\u044f \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ol>\n<li>\n<p><strong>LogCleaner<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043b\u043e\u0433 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c <strong>logHead<\/strong>\/<strong>logTail<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 offset&#8217;\u044b \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0432 <strong>logHead<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0441\u0430\u043c\u044b\u0439 \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442, \u0443\u0434\u0430\u043b\u044f\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043b\u044e\u0447\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u043b\u043e\u0433\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u043d\u0430 \u0441\u0436\u0430\u0442\u044b\u0439. <\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0430\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <strong>logCleaner<\/strong>:<\/p>\n<ul>\n<li>\n<p><em>log.cleanup.policy=compact<\/em> \u2013 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 <strong>log compaction<\/strong>;<\/p>\n<\/li>\n<li>\n<p><em>log.cleaner.max.compaction.lag.ms<\/em> \u2013 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043b\u044e\u0447 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u043b\u043e\u0433\u0443;<\/p>\n<\/li>\n<li>\n<p><em>log.cleaner.threads<\/em> \u2013 \u043a\u043e\u043b-\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 logCleaner.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043a\u043b\u044e\u0447\u0438 \u0441 \u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p><strong>\u0414\u0435\u0442\u0430\u043b\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b<\/strong><\/p>\n<p>Log compaction \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e Kafka \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0442\u043e\u043f\u0438\u0138\u0430. \u042d\u0442\u043e\u0442 \u0138\u0435\u0439\u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 key-value-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<br \/> \u0412 <a href=\"https:\/\/kafka.apache.org\/documentation\/#compaction\">\u0434\u043e\u0138\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <\/a>\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440 <em>user_id<\/em> -> <em>email<\/em>.<\/p>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u043e\u043f\u0438\u0138\u0430\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445:<\/p>\n<ul>\n<li>\n<p><em>cleanup.policy=delete<\/em> \u2013 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p><em>retention.bytes<\/em> \u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u0430, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p><em>retention.ms<\/em> \u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0436\u0438\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0138\u0430\u0138 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 log compaction.<\/p>\n<p>\u0421\u0138\u0430\u0447\u0430\u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e <a href=\"https:\/\/kafka.apache.org\/downloads\">Apache<\/a> <a href=\"https:\/\/kafka.apache.org\/downloads\">Kafka<\/a> (\u0432 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 2.7.0), \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c zookeeper \u0438 \u0431\u0440\u043e\u0138\u0435\u0440\u0430 \u0441 default-\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u0138\u0430\u043c\u0438:<\/p>\n<pre><code>.\/bin\/zookeeper-server-start.sh .\/config\/zookeeper.properties .\/bin\/kafka-server-start.sh .\/config\/server.propertie<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u043e\u043f\u0438\u0138:<\/p>\n<pre><code>.\/bin\/kafka-topics.sh \\ --bootstrap-server localhost:9092\\   --create \\ --topic test \u2013 topic-1 \\   --config \"segment.bytes=1024\" \\   --config \"cleanup.policy=compact\" \\   --config \"cleaner.max.compaction.lag.ms =60000\"<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c consumer&#8217;a:<\/p>\n<pre><code>.\/bin\/kafka-console-consumer.sh \\   --bootstrap-server localhost:9092 \\   --property \"print.key=true\" \\   --property \"key.separator=    \" \\   --from-beginning \\   --topic test topic-1<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c producer&#8217;\u0430:<\/p>\n<pre><code>.\/bin\/kafka-console-producer.sh \\   --bootstrap-server localhost:9092 \\   --property \"parse.key=true\" \\   --property \"key.separator=:\" \\   --topic test topic-1<\/code><\/pre>\n<p>\u0412 \u043e\u0138\u043d\u0435 producer&#8217;\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>> a:1 > b:1 > c:1 > a:2<\/code><\/pre>\n<p>\u0412 \u043e\u0138\u043d\u0435 consumer&#8217;a \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u0432\u0441\u0435 \u0442\u0435 \u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0435\u0440\u0435\u0437 60\u201390 \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 consoleconsumer, \u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435:<\/p>\n<pre><code>b   1 c   1 a   2<\/code><\/pre>\n<p>\u0421\u0436\u0430\u0442\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0426\u041f \u0432\u0430\u0448\u0438\u0445 \u0431\u0440\u043e\u043a\u0435\u0440\u043e\u0432.\u00a0\u0414\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u043d\u0443\u0436\u043d\u0430 \u043a\u0430\u043a \u043a\u0443\u0447\u0430 (\u043f\u0430\u043c\u044f\u0442\u044c), \u0442\u0430\u043a \u0438 \u0446\u0438\u043a\u043b\u044b \u0426\u041f \u043d\u0430 \u0431\u0440\u043e\u043a\u0435\u0440\u0430\u0445, \u0430 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u0442 \u0431\u0440\u043e\u043a\u0435\u0440\u043e\u0432 \u0440\u0438\u0441\u043a\u0443 \u0438\u0437-\u0437\u0430 \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u043e\u0441\u0442\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c\u00a0<strong><em>log.cleaner.dedupe.buffer.size<\/em><\/strong>\u00a0\u0438\u00a0<strong><em>log.cleaner.threads<\/em><\/strong>\u00a0\u043d\u0430 \u0441\u0432\u043e\u0438\u0445\u00a0\u0431\u0440\u043e\u043a\u0435\u0440\u0430\u0445, \u043d\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0443\u0447\u0438. \u0415\u0441\u043b\u0438 \u0431\u0440\u043e\u043a\u0435\u0440 \u0432\u044b\u0434\u0430\u0441\u0442\u00a0\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u00a0OutOfMemoryError, \u043e\u043d \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u0430 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0447\u0438\u0449\u0430\u0435\u043c\u044b\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u0442\u0435\u043c\u044b, \u0442\u0430\u043a \u0438 \u043e\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u043b\u044e\u0447\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u044d\u0442\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445.<\/p>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u2013 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 compacted topic&#8217;\u0430. <\/p>\n<p>\u0410\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438: <a href=\"https:\/\/habr.com\/ru\/users\/arsen_gl\/\">\u0410\u0440\u0441\u0435\u043d\u0438\u0439 \u0413\u043e\u043b\u0443\u0448\u043a\u043e\u0432<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438:<\/summary>\n<div class=\"spoiler__content\">\n<p><em>1.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"https:\/\/medium.com\/swlh\/introduction-to-topic-log-compaction-in-apache-kafka-3e4d4afd2262\"><em>https:\/\/medium.com\/swlh\/introduction-to-topic-log-compaction-in-apache-kafka-3e4d4afd2262<\/em><\/a><\/p>\n<p><em>2.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"https:\/\/towardsdatascience.com\/log-compacted-topics-in-apache-kafka-b1aa1e4665a7\"><em>https:\/\/towardsdatascience.com\/log-compacted-topics-in-apache-kafka-b1aa1e4665a7<\/em><\/a><em> <\/em><\/p>\n<p><em>3.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"http:\/\/cloudurable.com\/blog\/kafka-architecture-log-compaction\/index.html\"><em>http:\/\/cloudurable.com\/blog\/kafka-architecture-log-compaction\/index.html<\/em><\/a><em> <\/em><\/p>\n<p><em>4.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"https:\/\/kafka.apache.org\/documentation\/#intro_concepts_and_terms\"><em>https:\/\/kafka.apache.org\/documentation\/#intro_concepts_and_terms<\/em><\/a><em> <\/em><\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/590045\/\"> https:\/\/habr.com\/ru\/articles\/590045\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-393877","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=393877"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393877\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=393877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=393877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=393877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}