Scalper account detection with GraphCompute

Updated at:

In scenarios such as online transactions and user acquisition campaigns, scalper accounts can reduce campaign effectiveness and harm legitimate new users. This solution leverages rich graph relationships from multiple tables and the OneID system to quickly identify and locate scalper accounts, providing businesses with more accurate and explainable risk controls.

To help you get familiar with GraphCompute, we provide a complete OneID scalper account detection demo, including sample data, example queries, and a step-by-step guide. You can use it to quickly build a graph application and run scalper account detection and graph exploration at a million-record scale.

What is GraphCompute?

GraphCompute is a distributed graph query and computing solution that delivers high performance and high stability at a trillion-record scale. It also includes intelligent O&M and an offline system to enable data lake and data warehouse integration, and supports fast iteration and management across multiple data versions. Built on Alibaba’s experience across multiple industries such as e-commerce, security, and social networking, GraphCompute provides graph technology services for enterprises and developers worldwide.

Background

In today’s digital economy, data is a core driver of innovation and growth. Open data enables collaboration and innovation across industries and organizations, and it creates new business models. At the same time, as data value rises, attacks such as theft, abuse, and hijacking are becoming more frequent and more industrialized and sophisticated. Internet companies need to identify and track users. By linking information across accounts and devices, they can quickly understand account status and drive better business coordination and protection. We refer to this type of scenario as OneID identity resolution.

What is OneID?

OneID is a cross-device, cross-domain system that identifies and tracks real people. It is analogous to a government-issued ID in the physical world. For each person in the online world, OneID uses algorithms to assign a stable, virtual identity ID (a OneID) and links the various identity IDs they own.

Identity IDs fall into three categories: 

- Account IDs: Business accounts, phone numbers, email addresses, and more. 

- Device IDs: IMEI, IMSI, IDFA, and more. 

- Cookie-based IDs: Acookie, and more.

The OneID framework connects sparse information through entity relationships and aggregates it around a real person. For example, if a key device ID links to many account IDs, those accounts may belong to one person or be shared by a coordinated group. You can then discover scalper account networks or other illicit groups on your platform.

Why use graphs for risk mining?

Graphs represent relationships and behaviors efficiently. The industry uses graph computing to establish and categorize common graph schemas and relationship patterns. If you model your data around these patterns, you can summarize activity traces and use them for fraud prevention. In contrast, traditional fraud detection often focuses on outliers in a feature space and ignores real-world relationship data. In practice, entities have rich connections, and a graph structure provides additional information that improves fraud detection.

Scalper account identification

Business background

A technology company that sells AI digital products and solutions wants to prevent the abuse of promotional coupons. The primary goal is to implement OneID-based risk control for registered accounts to identify scalper accounts and fraudulent groups, thereby reducing financial losses.

Analysis of fraudulent behavior reveals a common pattern: maximizing the use of available device resources to create a large number of accounts. Detecting users who register multiple accounts to claim coupons requires multi-hop queries from one user to another.

This business logic can be abstracted as follows:

1) Query scenario: A two-hop relationship represented as Account A - Device G - Account B.

2) After identifying users linked by multiple devices, apply a weighting score to the device paths to determine the final risk.

image

Business analysis

In transaction fraud and spam registration scenarios, you can use graph data and a OneID system to quickly identify and locate scalper accounts and validate new users. This provides businesses with more accurate and explainable risk controls.

We start with offline algorithms. A common exploration path is from graph propagation algorithms to graph clustering algorithms and finally to graph representation algorithms to uncover risks over a wider and deeper scope. Initially, a graph propagation algorithm can quickly and accurately identify a small number of risk instances. However, this semi-supervised method is limited to local exploration around known risky entities. To expand the recall of risk instances from a global perspective, we use a graph clustering algorithm to uncover fraudulent groups. In addition to the graph structure, entity properties also help in risk detection. By fully incorporating account violation records, penalties, and behavioral features, you can gain more information and uncover deeper risks.

This scalper account detection scenario uses the first step, the graph propagation algorithm, as shown in the figure below. It propagates influence from known risky nodes to identify other high-risk nodes and calculate their corresponding risk scores.

image

Step 1: Organize log data

Collect and process user login and registration logs:

  • Define data: Confirm data sources and define the data format and fields for each source.

    • Log Service (SLS) collection: The raw data includes:

      • User login information

      • User registration information

      • Cookie information

  • Normalize and map data: Use a dedicated platform to define mappings from source data to tables and allow for scripted data processing.

    • [User information table]

      • Includes key information such as registered accounts and timestamps.

    • [Device information table]

      • Includes device types such as mobile phones, IP addresses, and email addresses.

  • Trigger incremental writes to the corresponding table when an event occurs.

    • After a new user registers and logs in, data is exported to update the [User information table] and [Device information table].

  • Persist data: Use MaxCompute to store full offline data.

Step 2: Select an offline algorithm

Community Search is a graph propagation algorithm that starts from the local information of known seed nodes in a network to discover the local community of a given seed node. It offers strong community-specific targeting. You can use a semi-supervised method that relies on existing labeled nodes to assign pseudo-labels to nearby unlabeled nodes and iteratively predict more unlabeled nodes.

In anti-fraud scenarios, you typically have only a small amount of labeled data but also need to process large amounts of unlabeled data that contain many risky instances. The key challenge is to mine these risky instances from the unlabeled data at scale. A semi-supervised workflow can address this: take business-provided risk data as the initial input, mine high-risk instances around it, send the mined instances back for business validation, then add the validated risky instances into the input and iterate to find more risky data. However, semi-supervised methods can only discover samples near labeled data and cannot discover groups with specific structures.

Well-known industry methods for mining risky entities on semi-supervised relational graphs include Amazon’s GraphRAD (2018) and Ant Group’s Risk-alike (2021). Both methods mine risk on a graph based on black seed nodes. You can also use link analysis methods such as PageRank to compute the importance of other nodes in the network starting from labeled nodes.

For example:

    Risk_alike

    Input: Black seed nodes and all edge relationships.

    Step 1: Build a graph from nodes within two hops of the black seed nodes.

    Step 2: Use the Louvain algorithm for community detection to find risk groups and recall nodes within two hops of each group. Then, apply rules to keep groups where the black-node ratio is >= 40% and the group size is <= 200.image

    Step 3: Use PageRank to compute and rank risk scores for each node. Starting from the black seed nodes, compute each node’s importance relative to the black seeds and use this value as its risk score.

    Step 4: Purify the results. Filter and output high-risk nodes based on the Louvain and PageRank results.

    Output: The discovered high-risk nodes and their corresponding risk scores.

    Alibaba Cloud's Platform for AI (PAI) includes built-in anti-fraud algorithms such as Risk-alike, Louvain, LPA, and PageRank that you can call directly. The final output includes the [User information table] with fields such as registered account and time, and a new user group label: isbad = true | false.

Step 3: Analyze and refine the models

Based on the business logic, we designed several models with different graph configurations.

Solution 1

Solution 2

Solution 3

image

image

image

Features: Heterogeneous edge tables.

This model is closest to the original data structure but requires excessive table configuration.

Features: Homogeneous edge tables.

Graph configuration is simple, requiring only two tables: a user vertex table and a device association table.

Features: Devices are modeled as independent nodes.

This model is more flexible for managing relationship changes for popular devices.

Problem: Device types cannot be added flexibly. Device edge tables must be added manually, which limits scalability.

Problem: To insert a new user, you must first query for relevant user relationships before insertion.

Problem: Sacrifices some query performance by adding a device-to-user query hop.

Step 4: Optimize the model

Based on business considerations, we choose Solution 3. The main reasons are as follows:

Reason 1: It supports fast lookups starting from a specified medium type, which makes filtering and statistical calculations by type more convenient.

Reason 2: It offers superior insert performance. To insert a new user, Solutions 1 and 2 require one or more queries to find related user relationships before the insertion. Solution 3 does not require this step. Solutions 1 and 2 require one vertex insertion and multiple edge insertions, whereas Solution 3 requires only one vertex insertion and two edge insertions. For a popular IP address, inserting a new user who shares that IP could require inserting tens of thousands of edges, which creates significant system overhead. Consider the following case: insert User D, where three existing users (A, B, and C) use the same IP address as D.

  • Solutions 1 and 2: Insert the vertex for User D, query all users who share the same IP as D, and then insert the edges. Before insertion: 3 vertices, 6 edges. After insertion: 4 vertices, 12 edges.

  • image

    image

  • Solution 3: Insert the vertex for User D. If the IP address does not exist in the table, insert the IP vertex (for example, 192.168.1.1) and then insert the forward and reverse edges between User D and the IP vertex. Before insertion: 4 vertices, 6 edges. After insertion: 4 (or 5) vertices, 8 edges.

  • image

    image

The main drawback is a trade-off in query performance: the number of hops from user to user increases from one to two. Overall, Solution 3 simplifies the offline update pipeline logic without a significant impact on performance.

Set up GraphCompute

Step 1: Define the graph schema

Based on the preceding business analysis, we use Solution 3 to configure the graph. This includes a vertex table for users (User), a vertex table for devices (medium), and an edge table for user-device relationships (relation).

image

Step 2: Choose a data source method

Select a method:

  • Method 1: MaxCompute data source + API data (Recommended): If you already use or plan to use MaxCompute, host your source data in MaxCompute and require 24/7 real-time updates to your graph data. This is the recommended approach.

  • Method 2: API data source: If you want to host data directly in GraphCompute and update it in real time 24/7 by using APIs.

  • Method 3: MaxCompute data source: If you are an advanced MaxCompute user, host your source data in MaxCompute, generate partitions on a schedule, and do not need 24/7 incremental updates to your graph data.

Step 3: Create the data source

Our quick start guide uses Method 1 (MaxCompute source tables + API data) and Method 2 (API data source).

[Method 1: MaxCompute source tables + API data]

This method relies on an existing MaxCompute project and source table data.

If you do not have existing data, you can use our provided demo data source, which already has vertices and edges defined.

If your business data already exists in CSV files or MaxCompute, you can select your own MaxCompute source data.

User source table

Use igraph_mock.anti_cheating_demo_user_vertex. The vertex table contains 100,000 users, of which 1% are risk accounts (isbad=TRUE).

You can use the following MaxCompute DDL statement to create the table:

  • You can add the isbad field as needed to mark known scalper users.

  • You can add more user information fields, such as name, gender, and registration time.

    CREATE TABLE IF NOT EXISTS anti_cheating_demo_user_vertex
    (
        user_id BIGINT COMMENT 'User account ID'
        ,isbad BOOLEAN  COMMENT 'Specifies whether the account is a risk account'
    )
    COMMENT 'User vertex table'
    PARTITIONED BY (ds STRING COMMENT 'Date partition');

Medium table

Use igraph_mock.anti_cheating_demo_medium_vertex. The table includes 100,000 media, of which 0.3% are used by more than one user.

You can use the following MaxCompute DDL statement to create the table:

  • Common medium_type values include phone number, email, IP, and device. This example includes only phone numbers and emails.

  • The weight field indicates the importance of the medium. Generally, you can use the same weight value for the same type of device. For example, it is not necessary to differentiate if multiple users share the same IP address.

    CREATE TABLE IF NOT EXISTS anti_cheating_demo_medium_vertex
    (
        medium_id BIGINT COMMENT 'Medium ID'
        ,medium_type STRING COMMENT 'Medium type'
        ,weight double  COMMENT 'Weight'
    )
    COMMENT 'Medium vertex table'
    PARTITIONED BY (ds STRING COMMENT 'Date partition');

User-medium edge table

Use igraph_mock.anti_cheating_demo_medium_edge. This table defines the relationships between the user and medium vertices.

You can use the following MaxCompute DDL statement to create the table:

The score field primarily indicates the frequency or importance of a user's medium usage. If you have no specific business logic, you can set the default value to 1.

CREATE TABLE IF NOT EXISTS anti_cheating_demo_user_medium_edge
(
    user_id BIGINT COMMENT 'User account ID'
    ,medium_id BIGINT COMMENT 'Medium ID'
    ,score double  COMMENT 'Weight'
)
COMMENT 'User-medium edge table'
PARTITIONED BY (ds STRING COMMENT 'Date partition');

[Method 2: API data source]

This method relies on writing and updating data by using the server-side SDK or the data writing window in the console.

For the console data writing window, go to **Graph O&M**, right-click a User or Relation, and select **Write Incremental Data**.

[MaxCompute source table guide]

You can follow these steps to create MaxCompute data tables:

Create data tables in DataWorks. Each vertex table and edge table requires its own separate data table.

  1. Go to DataWorks and select **DataStudio** in the upper-left corner.

  2. Go to **Business Flow** > **MaxCompute** > **Table**, right-click and select **Create Table**, and enter a table name.

    In the Create Table dialog box, the engine type defaults to MaxCompute. Enter the table name.

  3. Set the table properties.

    Project Name and Table Name (Important):

    These cannot be changed. Note the project name (MaxCompute engine instance) and table name, as you will need to grant permissions to the GraphCompute account.

    In Basic Properties, you can set a Display Name and description for the table.

    Physical Model Design:

    Partition Type: Select **Partition Table**.

    TTL: Setting a lifecycle means that each partition of the table is automatically deleted after a specified number of days. Select this option as needed.

    Table Structure: Add the column properties for the table one by one, including column name, type, and whether it is a primary key. Choose field types that best match the field's properties (for example, use float instead of double if high precision is not required, and use int instead of string for numeric IDs). This helps reduce the index size and speeds up data backflow.

    Warning

    Note: GraphCompute currently has limitations on field types. It only supports the basic data types of MaxCompute 1.0 and 2.0, and does not support complex types (ARRAY, MAP, STRUCT). For specific field type definitions and value ranges, see the MaxCompute 2.0 data types documentation.

Step 4: Create the GraphCompute service

Step 4-1: Purchase an instanceLink

  • **Region**: To reduce network latency, select a region that is close to your location.

  • **Username and Password**: Used for access authentication during requests.

  • **Specifications**: Select the specifications based on your data volume and request complexity.

    • We recommend selecting the **Exclusive General-purpose** specification family.

    • If your business has complex computing requirements or high-performance demands, we recommend increasing the number of shards.

    • Reference specifications:

      • For data volumes in the millions, the following configuration is generally sufficient.

        We recommend the Exclusive General-purpose specification family with a local SSD type (4 vCPU, 16 GB memory, 240 GB disk), a replica count of 2, and a shard count of 1.

      • If the data volume is very large, increase the **number of shards**.

      • If online query traffic increases, you can increase the **number of replicas**.

After purchase, wait about 15 minutes for the instance to initialize.

Important

Promotion: New enterprise-verified users can get a free one-month trial on their first purchase.

Step 4-2: Create the graph schema

Based on the graph schema defined in Step 1, you can now create it. In the list on the right, select Graph List, click Create, and enter a name and description for the graph.

Step 4-3: Create vertex tables

Create the [User] vertex table

  1. In the upper-left corner, select Add Node and enter a name for the vertex.

  2. For **Data Source**, select MaxCompute Data Source + API Update.

  3. Enter the MaxCompute project name and table name.

    User source table: Use Project Name: igraph_mock, Table Name: anti_cheating_demo_user_vertex.

  4. Click Import Fields to automatically import the field names and type mappings for the corresponding table in MaxCompute.

  5. Select your primary key (pkey) and adjust the field types based on the data. Note that GraphCompute table types differ slightly from MaxCompute types. Choose the most appropriate integer type range (for example, INT8, INT32, INT64) to significantly reduce request response times.

    For Index Type, generally select KV. After configuration, the field list displays user_id (INT64, pkey field) and isbad (STRING).

    If you need an inverted index, select Inverted Index and use Add Index to add index fields. This enables global statistics and queries for scenarios where you need to perform global queries on attributes, such as "query all risk users."

    If you need to add extra fields, use Add Fields.

    If you need to enable automatic backflow for DONE partitions, turn on the Scan DONE Partition switch. For details, see the .done partition guide.

Create the [medium] vertex table

Medium source table: Use Project Name: igraph_mock, Table Name: anti_cheating_demo_medium_vertex.

The configuration is the same as for the user vertex. Select MaxCompute Data Source + API Update as the data source. The fields include medium_id (INT64, pkey field), medium_type (STRING), and weight (DOUBLE). Select KV as the index type.

Step 4-4: Create edge tables

Create a forward edge from user to medium

  1. Select the user vertex, right-click it and select Add Edge, choose the destination vertex for the edge, and enter a name for the edge.

  2. Select MaxCompute Data Source + API Update as the data source.

  3. Enter the project name and table name, then import the fields.

    Edge source table: Use Project Name: igraph_mock, Table Name: anti_cheating_demo_user_medium_edge.

  4. Select the source and destination fields and adjust the field types based on the data.

    Source Field (pkey): user_id

    Destination Field (skey): medium_id

    If you need to add extra fields, use Add Fields.

    If you need to enable automatic backflow for DONE partitions, turn on the Scan DONE Partition switch. For details, see the .done partition guide.

  5. Click Submit.

Create a reverse edge from medium to user

  1. Select MaxCompute Data Source + API Update as the data source.

  2. Enter the project name and table name, then import the fields.

    Edge source table: Use Project Name: igraph_mock, Table Name: anti_cheating_demo_user_medium_edge.

  3. Select the source and destination fields and adjust the field types based on the data.

    Source Field (pkey): medium_id

    Destination Field (skey): user_id

Step 4-5: Publish the graph schema

After the user vertex, medium vertex, and relation edge tables are created, click Save and then Publish.

Step 4-6: Build the data index

After the graph schema is published, you can start building the index for GraphCompute. Click the batch backflow function to trigger index construction for large volumes of data.

  • **Partition Selection**: Choose a partition that fits your data.

  • **Incremental Timestamp**: When switching data online, this is the start time for replaying incremental data.

In the dialog box that appears, select a partition and incremental timestamp for medium, user_medium, and medium_user respectively, then click Trigger All.

The time required for data index construction depends on the data volume. For millions of records, it typically takes 15-20 minutes. You can verify completion in the **Graph O&M** tab by checking if the vertices and edges in the graph schema are green.

Step 4-7: Assess account risk

Assess risk based on factors such as the size of a fraudulent group.

Query with GraphCompute

After completing the previous steps, your graph application and data are ready. You can query and analyze the graph data. Use graph exploration for interactive analysis or the console for Gremlin query statements.

Graph exploration provides a visual representation of vertex relationships. You can enter a vertex ID to query and display its connections in a graph format.

The Query in the Console page provides an input box for Gremlin statements. Query results are displayed in a JSON tree structure.

Query examples

Direct query
// Query a user's information to determine if they are a risk user.
g("anti_cheating").V("-889411487137524591").hasLabel("user")

Indirect query
// Query the number of risk users associated with a specific medium.
g("anti_cheating").V("-3161643561846490971").hasLabel("medium")
.outE().inV()
.filter("isbad=\"true\"").count()

// Query the number of risk users who use the same medium as a specific user.
g("anti_cheating").V("-189711352665847917").hasLabel("user").
.outE().outE().inV()
.filter("isbad=\"true\"").count()

Pruning with weights
// Some super-media, such as a university's IP address, may be used by hundreds of thousands of users simultaneously.
// In this case, we recommend using sample(n).by("score") to randomly select n associated users for inspection. 
// The higher the score, the more likely the user is to be selected.
g("anti_cheating").V("-189711352665847917").hasLabel("user").
.outE().sample(10).by("score").outE().inV()
.filter("isbad=\"true\"").count()

Calculate risk score using weights
g("anti_cheating").withSack(supplier(normal,"0.0"),Splitter.identity,Operator.sum).
V("2532895489060363835").hasLabel("user").outE().sack(Operator.assign).by("to_double(score)").
inV().sack(Operator.mult).by("to_double(weight)").outE().inV()
.filter("isbad=\"true\"").barrier().sack()

Technical value of GraphCompute

Many types of graph products are available on the market, each with unique advantages. Because industries and use cases vary, you should understand product differences to make a targeted choice. GraphCompute provides strong real-time write performance and is built for massive graph storage and fast queries. Through engine indexing and operator optimizations, it improves query stability. It also provides strong fault tolerance for data import through constraint logic and self-developed operators, and repeated writes overwrite older data with the latest version. With one-stop intelligent O&M, it delivers a complex distributed graph engine while reducing operational overhead for users.

Advantages of the GraphCompute solution:

1. Low cost

GraphCompute’s proxy-search multi-layer architecture improves resource utilization, saving up to 50% on machine resources. It also doubles cluster QPS capacity.

2. High performance

Vertex splitting and multiple KKV types classify data during index building, and customizable truncation logic protects query performance. GraphCompute has extensive experience handling hot keys. Multi-level caching helps defend against these scenarios and supports dynamic scaling. Compared with open source solutions, query response time (RT) is two to six times faster.

3. Millions of updates per second

In risk control, OneID identity resolution is a common capability for finance and internet companies that requires real-time decisions. This scenario requires massive update throughput and strong graph query performance with a focus on OLTP. With an eventual consistency approach, GraphCompute supports a single-node update throughput of millions of QPS with updates becoming visible in 1 to 2 seconds. This keeps risk control data current to the second and improves detection accuracy.

4. Data warehouse integration

Connect to offline processing platforms. Risk control and security teams often build end-to-end big data analysis pipelines. With MaxCompute as the data warehouse, GraphCompute integrates seamlessly with data sources and supports fast iteration of full warehouse data, reducing data iteration cycles from days to hours.