外观
antispam-business-liveaudio — 直播语音内容安全
分层:业务层 | 部署单元:7 个(k8s 实部署 6 个) | 数据库:MySQL / TiDB(库
antispam) | base image:private-registry.nis.netease.com/library/base-image:jdk17(tagbase-250409)
一、模块定位与架构
模块是易盾「直播语音」(语音直播/音频直播)内容安全产品:客户交一路直播流地址后,模块在不打断直播的前提下对整场直播持续做流式反垃圾检测(涉黄、涉政、涉暴、广告、谩骂、语种、声纹、尖叫、年龄性别、主播风险分),并支持弹幕推送、语音墙监控、异常分累计,最后回传结论并计量计费。
架构分层
- 协议层:
facade/http-check-api(/v1..v4/liveaudio/check检测提交)、facade/http-api(回调/查询/反馈/播放/弹幕)、facade/dubbo-check-provider(checker 编排)、facade/dubbo-provider(数据查询/管理) - 逻辑层:
storage(消费 Kafka、证据处理与结果组装、断句合并)、service/business(ES/Redis/Kafka 封装) - 数据层:
service/base(DAO/Manager)、storage落live_audio*系列表 - 公共:
common、domain、service、facade/{dubbo-api,dubbo-check-api}、scheduler、console/api、file/doc、file/sql
关键数据流(持续检测)
LiveAudioCheckController.check→ 校验(签名/区域/参数/限流/并发兜底/重复提交)- Dubbo
LiveAudioCheckFacade.checkAudio→ 成功则发REQUEST_STAT计费 +Antispam_Live_Audio_Av_Evidence(SAVE_DB_CONTROL) LiveAudioSubmitHandler入库,状态STREAM_CHECK;直播期间持续向Antispam_Live_Audio_Evidence_New投断句证据AsrLiveAudioEvidenceHandler等各*EvidenceHandler→LiveAudioDataCheckServiceProvider(checker 编排)→LiveAudioMergaDataTask断句合并LiveAudioScoreService累计异常分 →ActiveCallbackHandler主动回调客户;结论落 DB/ES 供语音墙与人工审核
二、可部署服务清单
| 部署单元目录 | artifactId | 镜像名 | 端口 | 服务类型 | 独立 Dockerfile | 是否进 kubernetes.yml |
|---|---|---|---|---|---|---|
facade/dubbo-provider | antispam-business-liveaudio-facade-dubbo-provider | antispam-business-liveaudio-dubbo-provider | 无 HTTP(Dubbo) | Dubbo Provider(查询/管理) | 有 | 是 |
facade/dubbo-check-provider | antispam-business-liveaudio-facade-dubbo-check-provider | antispam-business-liveaudio-dubbo-check-provider | 无 HTTP(Dubbo) | Dubbo Provider(checker 编排) | 有 | 是 |
facade/http-check-api | antispam-business-liveaudio-facade-http-check-api | antispam-business-liveaudio-http-check-api | base 8080 / private 8702 | HTTP 检测提交 | 有 | 是 |
facade/http-api | antispam-business-liveaudio-facade-http(无 -api 后缀) | antispam-business-liveaudio-http-api | base 18129 / private 8080 | HTTP 回调/查询/弹幕 | 有 | 是(k8s Deployment 名 …-facade-http-api,与 artifactId 不一致) |
storage | antispam-business-liveaudio-storage | antispam-business-liveaudio-storage | 无 HTTP(Kafka 消费) | Kafka 消费落库 | 有 | 是 |
scheduler | antispam-business-liveaudio-scheduler | antispam-business-liveaudio-scheduler | 无 HTTP(定时任务) | Elastic-Job | 有 | 是 |
console/api | antispam-business-liveaudio-console-api | — | — | 控制台后端骨架 | 无(不构建) | 否 |
common、domain、service/base、service/business、service、facade/dubbo-api、facade/dubbo-check-api、facade、file为非部署库模块。
三、同模块启动顺序
facade/dubbo-check-provider— checker 编排能力注册 ZK(CheckerFactory),检测前置facade/dubbo-provider— 数据查询/管理 Dubbo 服务,供 http-api 与 CMS 调用facade/http-check-api— 提交入口,提交前需 Dubbo 检测能力可用facade/http-api— 回调/查询/弹幕入口,依赖同库 DAO 与 Dubbo 提供方storage— 消费Antispam_Live_Audio_*与 CDC;StorageConfiguration上@EnableKafka,Kafka 不可达起不来scheduler— Elastic-Job(归档/清理/评分/计费),需 ZK、DB、ES
理由:Dubbo 提供方先于消费方;storage 需先于 http-api 的回调结果消费,Kafka topic 与 Redis 缓存 key 必须已可用。
四、逐服务启动逻辑
facade/http-check-api
- 启动类:
com.netease.is.antispam.facade.http.check.HttpCheckApplication(facade/http-check-api/.../HttpCheckApplication.java,注意包名不含liveaudio) - exclude:
DataSourceAutoConfiguration @Enable*:@EnableOssClient、@EnableBusinessClient、@EnableRateLimiter、@EnableRecoverComponent、@EnableI18nComponent、@EnableApolloConfig、@PropertySources({@PropertySource("classpath:liveaudio-oss.properties")})- 配置类:
configuration/HttpFacadeConfiguration(@Configuration + @ComponentScan({"com.netease.is.antispam.facade.http.controller","…liveaudio.component.limter","…facade.http.zookeeper","…liveaudio.kafka","…liveaudio.redis","…liveaudio.monitor","…liveaudio.helper"})) main():无自定义;钩子:BarragePushServiceImpl @PostConstruct、ElasticRestSearchService @PostConstruct- Apollo:
app.id=antispam-liveaudio_http-check
facade/http-api
- 启动类:
com.netease.is.antispam.facade.http.HttpApplication(facade/http-api/.../HttpApplication.java) @SpringBootApplication(无 exclude):@EnableBusinessClient、@EnableCdcDataSubscribe(生效)、@EnableOssClient、@EnableRateLimiter、@EnableRecoverComponent、@EnableI18nComponent、@EnableApolloConfig、@PropertySources({@PropertySource("classpath:liveaudio-oss.properties")})- 配置类:
configuration/HttpFacadeConfiguration(@ComponentScan({"…facade.http.controller","…liveaudio","…facade.http.zookeeper","…liveaudio.service","…liveaudio.manager","…liveaudio.es","…liveaudio.integration","…liveaudio.cancel","…liveaudio.kafka","…liveaudio.monitor","…liveaudio.helper"})+@MapperScan("com.netease.is.antispam.liveaudio.dao")) main():无自定义- 钩子:
business/ContextRefreshedEventListener @PostConstruct(多处存在,异常会阻断启动) - Apollo:
app.id=antispam-liveaudio_http
facade/dubbo-provider
- 启动类:
com.netease.is.antispam.business.liveaudio.facade.dubbo.DubboApplication - exclude:
DataSourceAutoConfiguration @EnableAspectJAutoProxy、@EnableDubboAutoConfiguration(→DubboConfiguration:@ComponentScan+@MapperScan)、@EnableCdcDataSubscribe、@EnableOssClient、@EnableBusinessClient、@EnableRecoverComponent、@EnableApolloConfig、@PropertySources({liveaudio-oss.properties})main():无自定义;钩子:business/ContextRefreshedEventListener;Apollo:app.id=antispam-liveaudio_dubbo
facade/dubbo-check-provider
- 启动类:
com.netease.is.antispam.business.liveaudio.facade.dubbo.check.DubboCheckApplication - exclude:
DataSourceAutoConfiguration @EnableAspectJAutoProxy、@EnableDubboCheckAutoConfiguration(→DubboCheckConfiguration:@ComponentScan(component/kafka 等))、@EnableOssClient、@EnableBusinessClient、@EnableRecoverComponent、@EnableApolloConfig、@EnableConfigurationProperties({CheckerConfig.class})、@PropertySources({liveaudio-oss.properties})main():无自定义;Apollo:app.id=antispam-liveaudio_dubbo-check
storage
- 启动类:
com.netease.is.antispam.liveaudio.storage.StorageApplication @SpringBootApplication;@EnableScheduling、@EnableStorageAutoConfiguration(→StorageConfiguration:@ComponentScan({"…liveaudio.service","…liveaudio.manager","…liveaudio.component","…liveaudio.storage.zookeeper","…components.callback","…liveaudio.es","…liveaudio.integration","…liveaudio.kafka","…liveaudio.cancel","…liveaudio.redis","…liveaudio.monitor"})+@MapperScan("…liveaudio.dao")+@EnableKafka)、@EnableCdcDataSubscribe、@EnableOssClient、@EnableBusinessClient、@EnableRecoverComponent、@EnableApolloConfig、@EnableIsolateComponent、@PropertySources({liveaudio-oss.properties})main():无自定义- 钩子:
YidunQosApplication(doOffline()pause Kafka 容器并 sleep)、business/ContextRefreshedEventListener、LiveAudioInsertCache/LiveSpeakerCache @PostConstruct、LiveAudioSilentService @PostConstruct - Apollo:
app.id=antispam-liveaudio_storage
scheduler
- 启动类:
com.netease.is.antispam.liveaudio.scheduler.SchedulerApplication @SpringBootApplication;@EnableScheduling、@EnableSchedulerAutoConfiguration(→SchedulerConfiguration:@ComponentScan({"…liveaudio.service","…liveaudio.manager","…liveaudio.scheduler","…liveaudio.es","…liveaudio.kafka","…liveaudio.redis","…components.callback"})+@MapperScan)、@EnableCdcDataSubscribe、@EnableOssClient、@EnableBusinessClient、@EnableRecoverComponent、@EnableIsolateComponent、@EnableApolloConfig、@PropertySources({liveaudio-oss.properties})- 另有
configuration/elasticjob/ElasticJobConfiguration;main():无自定义 - 钩子:
YidunQosApplication、LiveAudioHistoricalArchiveCleanWorker/LiveAudioDataFix/LiveAudioMonitorFix @PostConstruct - Apollo:
app.id=antispam-liveaudio_scheduler
console/api
- 启动类:
com.netease.is.antispam.console.api.ConsoleApplication(EnableConsoleAutoConfiguration/SwaggerConfiguration) - 无 Dockerfile、不在 kubernetes.yml
共通:所有启动类
main()无业务自定义逻辑。
五、启动前置依赖
| 依赖 | 配置键/地址 | 阻塞 or 弱依赖 | 配置文件 |
|---|---|---|---|
| ZooKeeper | dubbo.registry.address=zookeeper://zk-0.zookeeper.yidun-infra:2181,group /yidun/antispam/online-new/yidun-antispam-dubbo;business root /netease-antispam/online/config | 阻塞 | application-private.properties |
| MySQL / TiDB | jdbc:mysql://tidb-cluster0-tidb.tidb.svc:4000/antispam(com.mysql.cj.jdbc.Driver,Druid) | 阻塞(http-api/http-check-api/dubbo-provider/storage/scheduler) | application-private.properties |
| Kafka / CDC | netease.kafka.producer.cluster.{main,log}.bootstrap.servers、cdc.kafka.bootstrap-servers=kafka-yidun-{0,1,2}.kafka-yidun-headless...:9092 | 阻塞(storage 的 @EnableKafka;http-api 的 CDC) | application-private.properties |
| Redis Sentinel | redis0-redis-ha.yidun-infra.svc:26379,master master01 | 阻塞(限流/缓存/语音墙) | application-private.properties |
| Elasticsearch | elasticsearch.cluster.servers.archive=http://elasticsearch-yidun-master.yidun-infra.svc:9200 | 弱依赖 | application-private.properties |
| OSS | classpath:liveaudio-oss.properties(@PropertySource) | 弱依赖(录制/切片/播放) | liveaudio-oss.properties |
| 取消/网关服务 | antispam.liveaudio.cancel-url=http://audio-gateway.yidun-ai.svc/gateway、cancel-av-url=http://av-api.nis.service.163.org | 弱依赖 | application-private.properties |
| Apollo | app.id=antispam-liveaudio_*,apollo.cache-dir=./apollo/cache,apollo.meta=http://yd-apollo-config.nistest.netease.com | 阻塞(apollo.bootstrap.enabled=true) | application.properties |
六、启动参数与 Profile
-Dspring.profiles.active:默认dev;Dockerfile 与 k8s 覆盖为private- Maven profile:
buildAll.sh以-P private全量构建后遍历build.sh;模块build.sh -e <env> - JAVA_OPTS(Dockerfile):
-Xmx1024m -Xms1024m -XX:+UseG1GC -Dspring.profiles.active=private - JAVA_OPTS(k8s 覆写):
-Xmx1024m -Xms1024m -XX:+UseG1GC -Dspring.profiles.active=private(注意双空格) - base image:
private-registry.nis.netease.com/library/base-image:jdk17;DockerfileENV APP_NAME=antispam-business-liveaudio-facade-<unit>;build.sh 推private-registry.nis.netease.com/yidun/antispam-business-liveaudio-<unit>;k8s 拉private-registry.yidun.internal/yidun/antispam-business-liveaudio-<unit>:1.0.0.private(tag1.0.0.private) - k8s 通用:namespace
yidun,replicas=2,env 注入ENABLE_SKYWALKING=true、SW_AGENT_COLLECTOR_BACKEND_SERVICES=skywalking-skywalking-oap.yidun-infra.svc:11800;http-check-api / http-api 配livenessProbe/readinessProbe(path: /health/status) - Dubbo 协议细节:
dubbo.protocol.port=-1(随机)、dispatcher=message、threads=300、payload=83886080
七、启动期踩坑
- artifactId 与 k8s 名不一致:http-api 的 artifactId 是
antispam-business-liveaudio-facade-http(无-api),而 kubernetes.yml 的 Deployment 名为…-facade-http-api;镜像名又是antispam-business-liveaudio-http-api,三处口径都不同。 - 端口特殊:http-api base profile 是
18129(private 未覆写、回落默认 8080),http-check-api base 默认8080、private 是8702;而 k8s Service 与探针统一走80(targetPort: 80),部署时务必核对实际监听端口,否则探针失败导致反复重启。 storage的StorageConfiguration标注@EnableKafka,Kafka 不可达时该单元直接起不来(不像其它模块靠平台消费组件容错)。DubboApplication/DubboCheckApplication/HttpCheckApplication均exclude=DataSourceAutoConfiguration,http-check-api不接受数据源自动装配,误配 DB 会引来无谓报错。http-api启用@EnableCdcDataSubscribe(生效),CDC 源(cdc.kafka.bootstrap-servers)是硬前置。- 多个
ContextRefreshedEventListener(@PostConstruct风格)散布在 dubbo-provider / http-api / storage,加载异常会阻断启动,需按包定位。 - properties 内明文存放
spring.redis.password、liveaudio.segment.play.access-key/secret-key;引用文档时不要外泄。 http-api有business.client.autoStart=false(Dubbo/Storage 也如此),业务配置缓存需在应用内显式触发启动,否则启动后短期取不到 target/secret。
八、跨模块前置
antispam-business:SecretInfoCache/ProductCache/TargetCache/TargetConfigCache/TargetCheckerCache与TargetType/ProductType/BusinessType枚举——硬前置antispam-bill:提交成功发REQUEST_STAT,机审/人审结果发Antispam_Bill_CensorStat计量消息antispam-list:IP 区域解析IpRegionCheck/IpRegionDetail;名单检测antispam-keyword/antispam-rule/antispam-textclassify:检测链 checker Dubbo 依赖antispam-business-audio:复用点播语音模块的AudioStatus枚举(com.netease.is.antispam.audio.common.enums.AudioStatus)antispam-cms:控制台经facade/dubbo-provider查询/更新直播语音数据、语音墙统计与人审操作- 共享组件
components:KafkaSender、YidunLogger、ActiveCallbackData、KafkaIsolateHelper、@KafkaConsumer、YidunQosApplication - 基础设施:ZooKeeper、Kafka、Redis Sentinel、MySQL/TiDB、Elasticsearch、Apollo、OSS