
By Junqi
Agents are changing the way we interact with software. However, a core pain point has always troubled developers and users: the "amnesia" of AI. Every conversation feels like a first meeting. AI is unable to remember user preferences, historical interactions, and business contexts.
Imagine this scenario: You tell the AI customer service that you are a VIP user, you are sensitive to prices, and you prefer Sichuan cuisine. Three days later, when you consult again, it asks you, "What are your taste preferences?" This experience not only frustrates the user but also makes the agent miss the opportunity for personalized service.
To address this issue, Alibaba Cloud PolarDB-X introduces the new fully managed long-term memory service Mem0. With a unique dual-channel architecture, this service provides a one-stop solution to the AI memory storage problem. This service allows agents to truly possess long-term memory capabilities.
PolarDB-X Mem0 is not a simple conversation record storage. Instead, it is an intelligent memory operating system.
It can automatically fetch key facts and preferences from the conversations between AI and users. For example, if a user says, "I want to find a Sichuan restaurant with an average cost of about 100," the system automatically fetches core facts such as "the user likes Sichuan cuisine," "the user is sensitive to price," and "the user's city," and stores this knowledge as structured data. When the user visits again, the AI can instantly recall all of this and provide truly personalized service.
More importantly, PolarDB-X provides the industry's unique dual-channel architecture. Channel A automatically stores and retrieves unstructured knowledge, such as what the user likes and what preferences the user has, through the Mem0 API. Channel B directly connects to the database through the MySQL protocol to store structured business data such as user personas, order records, and session logs. The two channels share the same PolarDB-X instance. You do not need to purchase additional databases.

As shown in the figure, the user accesses the same PolarDB-X cluster through two channels. Channel A passes through the API gateway and Mem0 server cluster for the add, search, and management of semantics memory. Data is stored in the vector table of the search engine. Channel B directly connects to PolarDB-X through the MySQL protocol to create and manage custom structured data tables in the InnoDB storage engine. This design allows users to enjoy the intelligent memory fetch and retrieve capabilities of Mem0 while directly using familiar relational database operations.
As a cloud-native distributed database, PolarDB-X brings enterprise-level extension capabilities and stability guarantees to Mem0.
First is the distributed extension of the storage tier. The vector storage engine of PolarDB-X natively supports horizontal extension. For memory data ranging from millions to tens of billions, you can achieve linear scale-out simply by increasing data nodes. This means that your AI application can start by serving hundreds of users and gradually extend to serving tens of millions of users without changing the storage architecture. Traditional standalone vector databases often face performance bottlenecks after the data volume increases. The distributed storage of PolarDB-X easily solves this problem.
Second is the high concurrency architecture of the compute layer. The REST service of PolarDB-X Mem0 adopts a four-layer concurrent design. Multiple processes bypass Python GIL limitations to fully utilize multi-core CPUs. The asynchronous event loop achieves efficient I/O multiplexing. The thread pool bridging offloads synchronous blocked memory operations to backend threads. The object pool reuses expensive memory instances to avoid frequent rreation and destroy. On an 8-core machine, this architecture achieves a throughput increase of tens of times compared to open source solutions. The P99 latency is reduced by more than 90%.
Third is comprehensive production-level protection. PolarDB-X Mem0 integrates multilayer protection mechanisms. Token bucket rate limiting isolates traffic by IP. This allows burst requests while controlling the long-term average rate. request timeout control prevents slow requests from occupying resources. Request body size limits block malicious large requests. The backpressure mechanism of the memory instance pool automatically queues requests when the pool is full to avoid crushing downstream services. These mechanisms keep the system stable under high payloads.
Finally, there are flexible extension methods. Vertically, you can increase single-machine performance by increasing the number of worker processes. Horizontally, you can deploy multiple instances through load balancing and share backend storage to achieve near-linear extension. It also supports Kubernetes automatic scaling to dynamically adjust the number of instances based on payloads. No matter how the business size changes, PolarDB-X Mem0 can handle it with ease.
Mem0 hosting solutions on the market only solve the problem of semantic memory. If you need to store business data such as user personas and conversation history, you have to purchase an additional relational database. This means two systems, two sets of costs, and double O&M complexity. The dual-purpose design of PolarDB-X allows you to obtain both vector semantic retrieval capabilities and relational data storage capabilities within a single instance. The number of instances is halved, and the architecture complexity is reduced to zero.
Distributed extension capability is the core advantage of PolarDB-X Mem0. Based on the PolarDB-X cloud-native distributed database kernel, the system natively supports horizontal extension. From lightweight applications of startups to massive user Scenarios of large platforms, a single architecture can fully cover the data storage of tens of billions of memories, high concurrency access of tens of thousands of QPS, and millisecond-level response latency. Traditional standalone vector databases often face a cliff-like drop in Performance after the data volume reaches the tens of millions level, while the distributed storage engine of PolarDB-X can smoothly extend to tens of billions of data, and the performance remains stable.
In terms of compatibility, PolarDB-X Mem0 is fully compatible with the open source Mem0 frame, and simultaneously supports the API specifications of the community version and the commercial version. Whether you previously used the open source version for self-hosting or hosting services from other cloud providers, you can migrate to PolarDB-X with zero code changes.
In terms of user experience, you do not need to build a vector database, configure Large Language Model (LLM) services, or process complex memory fetch logic. You can enable the service with one-click in the console, and connect to it through REST API or SDK in five minutes. Compared with self-built solutions, the comprehensive cost is reduced by more than half.
In terms of feature integrity, PolarDB-X Mem0 is not only compatible with all the basic capabilities of the open source version, but also provides enterprise-level features such as batch operations, data exporting, data summaries, project management, and webhook. The open source version has only 9 API endpoints, while PolarDB-X provides 25, and fully supports the MemoryClient SDK.
Intelligent customer service is the most typical scenario. Traditional customer service robots start from scratch in every conversation, while PolarDB-X Mem0 allows the customer service agent to remember everything about the user. When the user consults again, the Agent can directly ask, "Mr. Zhang, has your projector issue from last time been resolved? You previously provided feedback that you are sensitive to noise, so this time I recommend a silent model for you." This continuous experience upgrades the service from a cold program to a dedicated assistant, and user satisfaction is significantly improved.
Personalized recommendation is another important scenario. By combining semantic memory and structured profiles, the AI can provide precise recommendations. For example, if the system knows that the user recently follows outdoor gear, and also knows that the user is 28 years old, located in Shanghai, and has a monthly average Consumption of 3,000 yuan, it can say, "Based on the hiking shoes you previously browsed and your location in Shanghai, I recommend a waterproof model suitable for the rainy season, which happens to be available in size 42 that you usually wear." The recommendation accuracy is greatly improved, the conversion rate is increased, and the user experience changes from being marketed to being understood.
In intelligent education scenarios, the system records students' weak knowledge points, learning habits, and history of incorrect questions. When a student asks a question again, the agent will say, "You got 3 questions wrong on the quadratic function application questions last week. Today, we will first consolidate this knowledge point." Learning efficiency is improved, blind repetitive practice is avoided, and true personalized teaching is achieved.
In the healthcare realm, the system stores patient medical histories, allergy records, and medication history. When a patient consults about new symptoms, the Agent can associate the diagnostics data from half a year ago, provide advice with temporal depth, and remind about medication conflicts, achieving full-cycle medical services.
After an E-commerce platform is connected to PolarDB-X Mem0, its intelligent customer service agent achieves true long-term memory. The following are the core connection code and actual run effects.

First, you can encapsulate the memory manager to operate semantic memory and structured memory simultaneously.
class AgentMemoryManager:
def __init__(self, mem0_client, mysql_pool):
self.mem0 = mem0_client
self.pool = mysql_pool
# channel A: semantic A memory
def add_semantic_memory(self, messages, user_id):
return self.mem0.add(messages=messages, user_id=user_id)
def search_semantic_memory(self, query, user_id):
return self.mem0.search(query=query, user_id=user_id)
# channel B: structured B memory
def upsert_user_profile(self, user_id, nickname, city, vip_level):
conn = self.pool.connection()
try:
with conn.cursor() as cursor:
cursor.execute("""
INSERT INTO user_profiles (user_id, nickname, city, vip_level)
VALUES (%s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
nickname=VALUES(nickname), city=VALUES(city)
""", (user_id, nickname, city, vip_level))
conn.commit()
finally:
conn.close()
Then, you can run the business process. During the first round of conversation, you can update the user persona, save the message, and fetch the semantic memory. During the second round of conversation three days later, you can search the semantic memory and combine it with the structured memory to provide a personalized reply.
def run_conversation():
memory = AgentMemoryManager(mem0_client, mysql_pool)
user_id = "user_10086"
# First round of conversation
memory.upsert_user_profile(user_id, "Xiao Ming", "Hangzhou", 3)
user_msg = "I want to find a good restaurant, preferably Sichuan cuisine, with an average cost of about 100 yuan per person."
memory.add_semantic_memory([
{"role": "user", "content": user_msg},
{"role": "assistant", "content": "Recommend Shuxiangyuan (95 RMB per person)"}
], user_id)
# The second round of dialogue three days later
user_msg_2 = "The restaurant you recommended last time was good. Are there any similar ones?"
results = memory.search_semantic_memory(user_msg_2, user_id)
# Retrieve Result: likes Sichuan cuisine, 100 RMB per person, satisfied with Shuxiangyuan
During the first round of dialogue, the user said that the user wanted to find a delicious restaurant, preferably Sichuan cuisine, with a budget of about 100 RMB per person. The agent recommended a restaurant to the user, and simultaneously stored the user persona and dialogue records into the structured memory table and the semantics memory library respectively.
In the second round of dialogue three days later, the user said that the restaurant recommended last time was good. The agent retrieved from the semantics memory that the user preferred Sichuan cuisine and had a budget of 100 RMB per person, read from the structured memory that the user nickname was Xiaoming and the city was Hangzhou, and then responded: "Hello Xiaoming! I am glad you like Shuxiangyuan! Because you prefer Sichuan cuisine and have a budget of about 100 RMB per person, I will recommend a few more Sichuan cuisine restaurants in Hangzhou for you."
The agent not only remembered the user nickname Xiaoming, the city Hangzhou, the taste preference for Sichuan cuisine, and the budget of 100 RMB per person, but also remembered the previous recommendation results and the user feedback. All of these are stored in the same PolarDB-X instance. Semantics memory is managed through the Mem0 API. User persona and dialogue history are queried through MySQL direct connection. The two channels cooperate seamlessly.
More importantly, when the business size expands, the distributed capability of PolarDB-X allows all of this to require no refactoring. From serving hundreds of users to serving tens of millions of users, you can simply increase data nodes in the console. The system will automatically complete data redistribution, and the business will be unaware of it. In high concurrency scenarios, the multi-process architecture of PolarDB-X Mem0 can be horizontally extended. You can deploy multiple instances through load balancing, and share the same distributed storage backend to achieve a nearly linear performance improvement.
The launch of the PolarDB-X Mem0 managed service provides a brand new data infrastructure choice for enterprises to build AI applications.
Through the dual-channel, one-stop unique architecture, PolarDB-X not only solves the amnesia problem of the AI agent, but also helps enterprises quickly build truly memorable, empathetic, and resilient intelligent applications with a minimalist architecture, lower cost, and stronger extensibility.
In the LLM and agent technology wave, Data is no longer cold row and column records, but a cognitive carrier that endows machines with wisdom. The deep integration of PolarDB-X and Mem0 allows every developer to easily build a truly warm AI memory system.
Currently, the PolarDB-X Mem0 managed service is open for experience. You are welcome to visit the Alibaba Cloud official website to request a trial and start your agent evolution journey.
AgenticDB: Born from Alibaba Cloud AnalyticDB, Built for AI-Native Enterprises
PolarDB-X Snapshots: The " Undo Button" for Agent-Operated Data
ApsaraDB - June 21, 2026
ApsaraDB - May 11, 2026
ApsaraDB - June 11, 2026
Alibaba Cloud Native Community - January 21, 2026
Apache Flink Community - April 16, 2026
Alibaba Cloud Big Data and AI - April 13, 2026
Alibaba Cloud Model Studio
A one-stop generative AI platform to build intelligent applications that understand your business, based on Qwen model series such as Qwen-Max and other popular models
Learn More
PolarDB for PostgreSQL
Alibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn More
PolarDB for Xscale
Alibaba Cloud PolarDB for Xscale (PolarDB-X) is a cloud-native high-performance distributed database service independently developed by Alibaba Cloud.
Learn More
PolarDB for MySQL
Alibaba Cloud PolarDB for MySQL is a cloud-native relational database service 100% compatible with MySQL.
Learn MoreMore Posts by ApsaraDB