{"id":26027532,"url":"https://github.com/zlican/blog","last_synced_at":"2026-04-12T03:03:17.393Z","repository":{"id":275633801,"uuid":"926690749","full_name":"zlican/blog","owner":"zlican","description":"将博客系统和抽奖秒杀功能相结合的分布式应用。","archived":false,"fork":false,"pushed_at":"2025-03-05T15:04:31.000Z","size":2080,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-05T16:22:55.676Z","etag":null,"topics":["gin","mysql","redis","vue"],"latest_commit_sha":null,"homepage":"","language":"Vue","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/zlican.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}},"created_at":"2025-02-03T17:41:23.000Z","updated_at":"2025-03-05T15:04:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"bce8c736-1dbb-4a4b-9070-e1a1e15a124b","html_url":"https://github.com/zlican/blog","commit_stats":null,"previous_names":["zlican/blog"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlican%2Fblog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlican%2Fblog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlican%2Fblog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlican%2Fblog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zlican","download_url":"https://codeload.github.com/zlican/blog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242241948,"owners_count":20095463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["gin","mysql","redis","vue"],"created_at":"2025-03-06T16:22:32.530Z","updated_at":"2025-12-31T00:47:42.888Z","avatar_url":"https://github.com/zlican.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blog 博客秒杀系统\n将博客系统和抽奖秒杀功能相结合的分布式应用。\n\n### 技术栈\n\n前端：Vue3\n\n后端：Go + Gin + Gorm\n\n数据库：MySQL + Redis\n\n中间件：Kafka\n\n微服务通信：gRPC\n\n### 核心功能模块\n\n博客系统\n\n用户认证：采用 JWT 实现安全的身份验证\n\n文章管理：支持 Markdown 格式的文章编辑\n\n评论互动：实现用户间的互动交流\n\n分布式搜索：自研搜索引擎，支持文章快速检索\n\n抽奖秒杀系统\n\n大转盘抽奖：前端使用 lucky-canvas 实现流畅的抽奖动画\n\n库存管理：Redis 预热数据，实现高性能库存控制\n\n限流保护：令牌桶算法防止系统被恶意请求击垮\n\n异步处理：Kafka 消息队列处理订单生成和库存扣减\n\n### 项目亮点\n\n高并发架构设计\n\n采用微服务架构，将博客和抽奖系统解耦\n\nRedis 缓存热点数据，减轻数据库压力\n\ngoroutine 和 channel 实现并发控制\n\ngRPC 实现服务间高效通信\n\n数据一致性保障\n\n分布式锁确保库存操作原子性\n\n最终一致性方案处理分布式事务\n\nRedis + MySQL 双写一致性方案\n\n### 项目难点及解决方案\n\n秒杀系统的并发控制\n\n难点：大量用户同时抽奖导致系统压力剧增\n\n解决方案：\n\nRedis 预热库存数据\n\n令牌桶限流\n\ngoroutine 池化复用\n\n多级缓存架构\n\n分布式事务处理\n\n难点：跨服务操作的数据一致性保证\n\n解决方案：\n\n采用最终一致性方案\n\n引入消息队列作为补偿机制\n\n定时任务检查数据一致性\n\n系统可用性保障\n\n难点：高并发下的系统稳定性\n\n解决方案：\n\n服务熔断降级\n\n请求限流保护\n\n多级缓存策略\n\n异步处理解耦\n\n\n\n## 前端项目\n\n前端项目位于 `blog-frontend` 目录下，使用 Vue.js 构建。\n\n### 安装依赖\n\n```bash\ncd blog-frontend\nnpm install\n```\n\n### 运行前端项目\n\n```bash\nnpm run serve\n```\n\n前端项目将运行在 `http://localhost:5173`。\n\n## 后端项目\n\n后端项目位于 `blog-backend` 目录下，使用 Go 和 Gin 框架构建。\n\n### 安装依赖\n\n确保你已经安装了 Go 语言环境，然后运行以下命令安装依赖：\n\n```bash\ncd blog-backend\ngo mod tidy\n```\n\n### 运行后端项目\n\n```bash\ngo run main.go\n```\n\n后端项目将运行在 `http://localhost:8000`。\n\n## 配置\n\n### Redis 配置\n\n后端项目使用 Redis 作为 session 存储。你需要在本地安装并运行 Redis 服务器，默认连接地址为 `localhost:6379`。\n\n### CORS 配置\n\n后端项目配置了 CORS，允许来自 `http://localhost:5173` 的请求。如果你在生产环境中运行项目，请将 `config.AllowOrigins` 修改为你的前端项目地址。\n\n## 运行项目\n\n1. 启动 Redis 服务器。\n2. 启动后端项目：\n   ```bash\n   cd blog-backend\n   go run main.go\n   ```\n3. 启动前端项目：\n   ```bash\n   cd blog-frontend\n   npm run serve\n   ```\n\n现在，你可以在浏览器中访问 `http://localhost:5173` 查看博客项目。\n\n## 许可证\n\n该项目使用 MIT 许可证，详情请参阅 [LICENSE](LICENSE) 文件。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzlican%2Fblog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzlican%2Fblog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzlican%2Fblog/lists"}