Cost optimization
Costs depend on two factors:
-
Data volume: Determined by your business and cannot be optimized.
-
Configuration: align your settings with data volume to minimize costs.
Optimize configurations
Focus on two areas:
-
Number of shards
Each shard processes up to 5 MB/s. Only readwrite shards incur fees. Adjust shard count to match throughput and merge shards to reduce costs.
-
Logstore retention period
Set retention based on your query and storage needs:
-
For stream computing, use LogHub only and skip index creation.
-
If you frequently query recent logs (last 90 days) but rarely need older data, set the retention period to 90 days and import older data into MaxCompute. Use Simple Log Service for recent queries and MaxCompute for older data.
-
For long-term storage, ship logs to OSS.
-
Additional recommendations
-
Use Logtail for log collection. Logtail supports batch transmission and checkpoint-based resumption for real-time delivery, and uses 75% less CPU than open source alternatives such as Logstash or Fluentd.
-
Write logs via the API in large packages (64 KB to 1 MB) to reduce request count.
-
Index only key fields such as UserID and Action. Avoid indexing unnecessary fields.