# Using Grab’s Trust Counter Service to Detect Fraud Successfully

[Grab](https://yomu.fyi/company/grab) · Chao Wang · Oct 21, 2019

**Type:** Problem & solution

## Summary

Grab's Trust Platform team built the Counter service to detect fraud across business verticals like transportation, food, and payments. The platform replaces manual, multi-week engineering cycles with a self-service UI where data analysts can define and experiment with counters independently. Operating on an asynchronous ingestion and synchronous transaction model, the architecture evaluates incoming stream data, enriches it via internal services, and persists aggregated signals to ScyllaDB through Grab-Stats. A multi-bucket strategy partitions queries into fifteen-minute, hourly, and daily granularities to maintain low-latency query aggregations across wide time ranges under strict SLAs.

## Context

Conventional fraud rule creation required manual code changes, stream additions, and service redeployments taking two or more weeks per iteration, while lacking data consistency between offline machine learning models and real-time streams.

## Approach / What changed

Grab built a self-service Counter service featuring a UI rule editor, stream-processing counter engines, an SDK communicating over gRPC, and ScyllaDB-backed storage utilizing pre-aggregated multi-granularity time buckets (15-minute, 1-hour, and 1-day).

## Takeaways

- ScyllaDB was selected over in-memory stores like AWS ElastiCache because it was ten times cheaper, maintained equivalent stability, and achieved p99 read latencies under 150ms.
- Pre-aggregating event metrics into 15-minute, 1-hour, and 1-day buckets enables scalable querying across diverse time ranges without performing heavy on-the-fly database aggregations.
- The Counter service provides counter replay features across historical payloads to allow data scientists to evaluate and simulate new fraud features for machine learning pipelines.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [gRPC](https://yomu.fyi/topic/grpc), [Machine Learning](https://yomu.fyi/topic/machine-learning), [Performance](https://yomu.fyi/topic/performance), [Streaming](https://yomu.fyi/topic/streaming)

[Read original post](https://engineering.grab.com/using-grabs-trust-counter-service-to-detect-fraud-successfully)
