可扩展性原则 logo

可扩展性原则

Organization
microwind
可扩展性原则

设计系统使其能够通过增加资源来应对负载增长,支持水平和垂直扩展。

Overview

Publishermicrowind
Repositoryai-skills
Skill name可扩展性原则
Stars
93
Forks
25
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by microwind on GitHub. Read the source before you install it.

Installation

Install the 可扩展性原则 AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/microwind/ai-skills/tree/main/design-principles/scalability-principle
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/microwind/ai-skills.git /tmp/ai-skills
mkdir -p .claude/skills
cp -r /tmp/ai-skills/design-principles/scalability-principle .claude/skills/microwind-49
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable 可扩展性原则 in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads 可扩展性原则 on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so 可扩展性原则 is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

可扩展性原则 (Scalability Principle)

概述

可扩展性是系统应对增长的能力:当负载增加时,系统能通过增加资源来维持或提升性能。

扩展方式:

  • 垂直扩展(Scale Up):升级单机配置(更多CPU、内存)
  • 水平扩展(Scale Out):增加更多机器实例

水平扩展设计

java
// ❌ 无法水平扩展:状态存在内存中
@RestController
public class CartController {
    private Map<String, Cart> carts = new HashMap<>();  // 内存中的状态

    @PostMapping("/cart/{userId}/add")
    public void addItem(@PathVariable String userId, @RequestBody Item item) {
        carts.computeIfAbsent(userId, k -> new Cart()).addItem(item);
        // 另一台机器收到请求时看不到这个购物车
    }
}

// ✅ 无状态设计:状态外置
@RestController
public class CartController {
    private final CartRepository cartRepo;  // Redis / 数据库

    @PostMapping("/cart/{userId}/add")
    public void addItem(@PathVariable String userId, @RequestBody Item item) {
        Cart cart = cartRepo.findByUserId(userId).orElse(new Cart(userId));
        cart.addItem(item);
        cartRepo.save(cart);
        // 任何实例都能处理请求
    }
}

常见扩展策略

数据库扩展

读写分离:
┌─────────┐     写     ┌──────────┐
│  应用    │───────────→│  主库    │
│         │            └──────────┘
│         │     读      ┌──────────┐
│         │───────────→│  从库 1   │
│         │            ├──────────┤
│         │───────────→│  从库 2   │
└─────────┘            └──────────┘

分库分表:
用户 ID % 4 = 0 → DB_0
用户 ID % 4 = 1 → DB_1
用户 ID % 4 = 2 → DB_2
用户 ID % 4 = 3 → DB_3

缓存扩展

python
# 多级缓存
class CacheService:
    def __init__(self, local_cache, redis, db):
        self.local_cache = local_cache  # L1: 本地缓存
        self.redis = redis              # L2: 分布式缓存
        self.db = db                    # L3: 数据库

    def get(self, key: str):
        # L1
        value = self.local_cache.get(key)
        if value: return value

        # L2
        value = self.redis.get(key)
        if value:
            self.local_cache.set(key, value, ttl=60)
            return value

        # L3
        value = self.db.query(key)
        if value:
            self.redis.set(key, value, ttl=300)
            self.local_cache.set(key, value, ttl=60)
        return value

异步处理

typescript
// ❌ 同步处理:阻塞响应
app.post('/api/orders', async (req, res) => {
    const order = await createOrder(req.body);
    await sendConfirmationEmail(order);    // 耗时
    await updateInventory(order);          // 耗时
    await notifyWarehouse(order);          // 耗时
    res.json(order);  // 用户等了很久
});

// ✅ 异步处理:快速响应,后台处理
app.post('/api/orders', async (req, res) => {
    const order = await createOrder(req.body);
    await messageQueue.publish('order.created', order);  // 发消息
    res.json(order);  // 快速返回
});

// 后台消费者分别处理
messageQueue.subscribe('order.created', sendConfirmationEmail);
messageQueue.subscribe('order.created', updateInventory);
messageQueue.subscribe('order.created', notifyWarehouse);

可扩展性检查清单

□ 应用层无状态,状态存储在外部
□ 数据库有读写分离或分片策略
□ 耗时操作使用异步/消息队列
□ 有缓存层减少数据库压力
□ 支持配置化的连接池和线程池
□ API 支持分页,避免返回海量数据
□ 有负载均衡策略
□ 有容量规划和压测方案

与其他原则的关系

原则关系
关注点分离分离后的组件可以独立扩展
模块化模块化支持独立扩展
性能优先扩展性是性能的长期保障

总结

核心:无状态设计 + 状态外置 + 异步解耦。

关键策略:读写分离、缓存分层、消息队列、水平扩展。

Frequently asked questions

What does the 可扩展性原则 AI skill do?

设计系统使其能够通过增加资源来应对负载增长,支持水平和垂直扩展。

Why use 可扩展性原则 on TypingMind?

Because you install it once and use it with any model. 可扩展性原则 is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install 可扩展性原则 in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/microwind/ai-skills/tree/main/design-principles/scalability-principle. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use 可扩展性原则?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with 可扩展性原则?

As many as you like. As long as a model supports skills, you can use 可扩展性原则 with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the 可扩展性原则 AI skill free?

Yes. It is published on GitHub by microwind under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇