{"id":16599212,"url":"https://github.com/collabh/highconcurrent","last_synced_at":"2026-04-16T21:36:20.608Z","repository":{"id":105163902,"uuid":"185396869","full_name":"collabH/highconcurrent","owner":"collabH","description":null,"archived":false,"fork":false,"pushed_at":"2019-05-07T12:27:01.000Z","size":181,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-14T15:39:35.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/collabH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-07T12:25:15.000Z","updated_at":"2021-08-09T10:34:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"06aad584-f0cb-4e5f-a0a2-e4a332d39017","html_url":"https://github.com/collabH/highconcurrent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/collabH/highconcurrent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fhighconcurrent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fhighconcurrent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fhighconcurrent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fhighconcurrent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/collabH","download_url":"https://codeload.github.com/collabH/highconcurrent/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fhighconcurrent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31905890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T00:10:41.485Z","updated_at":"2026-04-16T21:36:20.597Z","avatar_url":"https://github.com/collabH.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 高并发\n\n## 扩容\n* 垂直扩容(纵向扩展):提高系统部件能力 \n* 水平扩容(横向扩展):增加更多系统成员来实现\n\n## 扩容-数据库\n* 读操作扩展:memcache、redis、CDN等缓存\n* 写操作扩展:Cassandra、Hbase等\n\n## 缓存\n**缓存特征**\n* 命中率:命中数/(命中数+没有命中数)\n* 最大元素(空间)\n* 清空策略:FIFO,LFU,LRU,过期时间，随机\n\n**缓存命中率影响因素**\n* 业务场景和业务需求\n* 缓存的设计(粒度和策略)\n* 缓存的容量和基础设施\n\n**缓存分类和应用场景**\n* 本地缓存：编程实现(成员变量、局部变量、静态变量)、Guava Cache\n* 分布式缓存：Memcache、Redis\n\n**缓存一致性**\n\u003e更新数据库成功-\u003e更新缓存失败-\u003e缓存不一致\n\u003e更新缓存成功-\u003e更新数据库失败-\u003e缓存不一致\n\u003e更新数据库成功-\u003e淘汰缓存失败-\u003e缓存不一致\n\u003e淘汰缓存成功-\u003e更新数据库失败-\u003e缓存不一致\n\n**解决缓存穿透**\n* 缓存空对象，如果查询为空的话可以缓存空对象，需要保存时效性\n* 对所有可能为空的key在请求做拦截 bitmap\n\n## 消息队列\n**为什么需要消息队列**\n* 【生产】和【消费】的速度或稳定性等因素不一致\n\n**消息队列好处**\n* 业务解耦（关心通知）\n* 最终一致性\n* 广播\n* 错峰与流控\n\n## 应用拆分\n**基本原则**\n* 业务优先（按照业务边界进行切割，再按照模块进行拆分）\n* 循序渐进（拆分和测试，边拆分边测试，保证拆分是完整的）\n* 兼顾技术：重构、分层\n* 可靠测试\n\n**应用拆分-思考**\n* 应用直接的通信：RPC(dubbo等 实时性更高)、消息队列\n* 应用之间数据库设计：每个应用都有独立的数据库\n* 避免事务操作垮应用\n\n## 应用限流\n**限流算法**\n* 计数器法 需要考虑临界\n* 滑动窗口 需要更多的存储空间\n* 漏桶算法  \n* 令牌桶算法 允许流量的突发\n\n# 服务降级与服务熔断\n* 服务降级--定制不同的默认和错误\n    * 自动降级：超时、失败次数、故障、限流\n    * 人工降级：秒杀、双11大促等\n* 服务熔断--某个原因使得服务过载后，会在一段时间是服务熔断\n    * 共性：目的、最终表现、力度、自治\n    * 区别：触发原因、管理目标层次、实现方式\n    \n# Hystrix\n* 通过第三方客户端访问(通常是通过网络)依赖服务出现高延迟或者失败时，为系统提供保护和控制\n* 在分布式系统中防止级联失败\n* 快速失败(Fail fast)同时能快速恢复\n* 提供失败回退(Fallback)和优雅的服务降级机制    \n\n# 数据库切库、分库、分表\n* 数据库瓶颈\n    * 单个库数据量太大(1T-2T):多个库\n    * 单个数据库服务器压力过大、读写瓶颈:多个库\n    * 单个表数据量过大：分表\n\n**数据库切库**\n* 切库的基础及实际运用：读写分离  (减轻主库的压力、使用动态数据源)\n* 自定义注解完成数据库切库-代码实现\n\n**数据库支持多个数据源与分库**\n* 支持多数据源、分库\n\n**数据库分表**\n* 什么时候考虑分表\n* 水平分表与垂直分表  \n* 数据库分表：mybatis分表插件shardbatis2.0\n\n# 高可用的一些手段\n* 任务调度系统分布式：elastic-job+zookeeper\n* 主备切换：apache curator+zookeeper分布式锁实现\n* 监控报警机制","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollabh%2Fhighconcurrent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcollabh%2Fhighconcurrent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollabh%2Fhighconcurrent/lists"}