| name | guidewire-cost-tuning |
| description | Optimize Guidewire Cloud costs including license management, resource allocation,
API usage optimization, and cloud infrastructure right-sizing.
Trigger with phrases like "guidewire costs", "reduce spending",
"license optimization", "cloud costs", "resource optimization guidewire".
|
| allowed-tools | Read, Write, Edit, Bash(curl:*), Grep |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
Guidewire Cost Tuning
Overview
Optimize Guidewire Cloud Platform costs through license management, API efficiency, resource right-sizing, and operational best practices.
Prerequisites
- Access to Guidewire Cloud Console billing
- Understanding of Guidewire licensing model
- Access to usage metrics and reports
Cost Components
| Component | Billing Model | Optimization Focus |
|---|
| Licensing | Per user/policy | User management, policy counts |
| API Calls | Per call/volume | Request optimization, caching |
| Storage | Per GB | Data retention, archiving |
| Compute | Per instance-hour | Right-sizing, auto-scaling |
| Data Transfer | Per GB | Efficient payloads, compression |
Instructions
Step 1: Analyze Current Usage
interface UsageMetrics {
period: string;
apiCalls: number;
activeUsers: number;
storageGB: number;
computeHours: number;
dataTransferGB: number;
}
interface CostBreakdown {
licensing: number;
apiCalls: number;
storage: number;
compute: number;
dataTransfer: number;
total: number;
}
class CostAnalyzer {
async getUsageReport(startDate: Date, endDate: Date): Promise<UsageMetrics> {
const token = await this.getToken();
const response = await fetch(
`${this.gccUrl}/api/v1/usage?start=${startDate.toISOString()}&end=${endDate.toISOString()}`,
{
headers: { : }
}
);
response.();
}
(: , : ): <> {
usage = .(startDate, endDate);
{
: .(usage),
: .(usage),
: .(usage),
: .(usage),
: .(usage),
:
};
}
(: ): [] {
: [] = [];
(usage. < usage. * ) {
optimizations.({
: ,
: ,
: (usage. - usage.) * .,
:
});
}
(usage. > usage. * ) {
optimizations.({
: ,
: ,
: usage. * * .,
:
});
}
(usage. > ) {
optimizations.({
: ,
: ,
: usage. * * .,
:
});
}
optimizations;
}
}
Step 2: License Optimization
interface UserActivity {
userId: string;
lastLogin: Date;
loginCount30Days: number;
role: string;
department: string;
}
class LicenseOptimizer {
async analyzeUserActivity(): Promise<UserActivityReport> {
const users = await this.getUserActivity();
const inactive30Days = users.filter(u =>
daysSince(u.lastLogin) > 30 && u.loginCount30Days === 0
);
const inactive90Days = users.filter(u =>
daysSince(u.lastLogin) > 90
);
const lowActivity = users.filter(u =>
u.loginCount30Days < 5 && u.loginCount30Days > 0
);
return {
totalUsers: users.length,
inactive30Days: inactive30Days.,
: inactive90Days.,
: lowActivity.,
: .(inactive30Days, inactive90Days, lowActivity)
};
}
(
: [],
: [],
: []
): [] {
: [] = [];
(inactive90. > ) {
recommendations.({
: ,
: inactive90.( u.),
: ,
: inactive90. * .
});
}
(inactive30. > ) {
recommendations.({
: ,
: inactive30.( u.),
: ,
: inactive30. * * .
});
}
(lowActivity. > ) {
recommendations.({
: ,
: lowActivity.( u.),
: ,
: lowActivity. * * .
});
}
recommendations;
}
}
Step 3: API Cost Optimization
class ApiCostOptimizer {
private callCounts: Map<string, number> = new Map();
trackCall(endpoint: string, responseSize: number): void {
const key = endpoint.replace(/\/[a-f0-9-]{36}/g, '/{id}');
this.callCounts.set(key, (this.callCounts.get(key) || 0) + 1);
}
analyzePatterns(): ApiOptimization[] {
const optimizations: ApiOptimization[] = [];
const topEndpoints = Array.from(this.callCounts.entries())
.sort((a, b) => b[1] - a[1])
.slice(0, );
topEndpoints.( {
(endpoint.() && count > ) {
optimizations.({
: ,
endpoint,
: count,
: ,
:
});
}
(endpoint.() && count > ) {
optimizations.({
: ,
endpoint,
: count,
: ,
:
});
}
});
optimizations;
}
}
{
: <, >;
: <, <>>;
getCached<T>(
: ,
: <T>,
: =
): <T> {
cached = ..(cacheKey);
(cached) {
cached;
}
result = ();
..(cacheKey, result, { : ttlMs });
result;
}
(: []): <[]> {
filter = accountIds.( ).();
..();
}
(: ): <> {
..(
);
}
(: , : ): <> {
compressed = (.(data));
..(endpoint, compressed, {
: {
: ,
:
}
});
}
}
Step 4: Storage Cost Optimization
// Data archiving and retention
package gw.cost.storage
uses gw.api.database.Query
uses gw.api.util.Logger
uses gw.transaction.Transaction
class StorageOptimizer {
private static final var LOG = Logger.forCategory("StorageOptimizer")
// Archive old claims
static function archiveOldClaims(olderThanDays : int) {
var cutoffDate = Date.Today.addDays(-olderThanDays)
var claimsToArchive = Query.make(Claim)
.compare(Claim#CloseDate, LessThan, cutoffDate)
.compare(Claim#State, Equals, ClaimState.TC_CLOSED)
.select()
.toList()
LOG.info("Found ${claimsToArchive.Count} claims to archive")
claimsToArchive.batch(100).each(\batch -> {
Transaction.runWithNewBundle(\bundle -> {
batch.each(\claim -> {
var c = bundle.add(claim)
c.archiveToExternalStorage() // Custom archive implementation
})
})
})
}
// Purge old audit logs
static function purgeAuditLogs(olderThanDays : int) {
var cutoffDate = Date.Today.addDays(-olderThanDays)
var deleted = Query.make(AuditLog)
.compare(AuditLog#CreateTime, LessThan, cutoffDate)
.delete()
LOG.info("Purged ${deleted} audit log entries")
}
// Compress document attachments
static function compressAttachments(claim : Claim) {
claim.Documents.each(\doc -> {
if (doc.Size > 1024 * 1024 && !doc.IsCompressed) { // > 1MB
Transaction.runWithNewBundle(\bundle -> {
var d = bundle.add(doc)
d.compress()
})
}
})
}
// Generate storage report
static function getStorageReport() : StorageReport {
var report = new StorageReport()
report.TotalDocumentsMB = calculateTotalDocumentSize()
report.TotalAuditLogsMB = calculateAuditLogSize()
report.TotalHistoryMB = calculateHistorySize()
report.ArchivableClaims = Query.make(Claim)
.compare(Claim#CloseDate, LessThan, Date.Today.addYears(-2))
.select()
.Count
report.PurgeableAuditLogs = Query.make(AuditLog)
.compare(AuditLog#CreateTime, LessThan, Date.Today.addDays(-90))
.select()
.Count
return report
}
}
Step 5: Compute Resource Right-Sizing
interface ResourceMetrics {
cpuUtilization: number[];
memoryUtilization: number[];
requestsPerSecond: number[];
timestamp: Date[];
}
class ResourceOptimizer {
async analyzeUtilization(days: number = 30): Promise<ResourceAnalysis> {
const metrics = await this.getMetrics(days);
const cpuP95 = percentile(metrics.cpuUtilization, 95);
const memoryP95 = percentile(metrics.memoryUtilization, 95);
const rpsP95 = percentile(metrics.requestsPerSecond, 95);
const recommendations: ResourceRecommendation[] = [];
if (cpuP95 < 40) {
recommendations.push({
resource: 'CPU',
currentUtilization: cpuP95,
recommendation: 'Reduce CPU allocation',
: .(cpuP95)
});
}
(memoryP95 < ) {
recommendations.({
: ,
: memoryP95,
: ,
: .(memoryP95)
});
}
utilizationVariance = (metrics.);
(utilizationVariance > ) {
recommendations.({
: ,
: ,
: ,
: .(metrics)
});
}
{
cpuP95,
memoryP95,
rpsP95,
recommendations
};
}
(): <> {
config = {
: ,
: ,
: ,
: ,
:
};
.(config);
}
}
Step 6: Cost Monitoring Dashboard
interface CostAlert {
threshold: number;
period: 'daily' | 'weekly' | 'monthly';
metric: string;
recipients: string[];
}
class CostMonitor {
private alerts: CostAlert[] = [];
addAlert(alert: CostAlert): void {
this.alerts.push(alert);
}
async checkAlerts(): Promise<AlertNotification[]> {
const notifications: AlertNotification[] = [];
for (const alert of this.alerts) {
const currentValue = await this.getCurrentValue(alert.metric, alert.period);
if (currentValue > alert.threshold) {
notifications.push({
alert,
currentValue,
exceededBy: ((currentValue - alert.threshold) / alert.threshold) * ,
: ()
});
}
}
notifications;
}
(): <> {
currentMonth = .();
previousMonth = .();
{
currentMonth,
previousMonth,
: ((currentMonth. - previousMonth.) / previousMonth.) * ,
: {
: currentMonth.,
: currentMonth.,
: currentMonth.,
: currentMonth.
},
: .()
};
}
}
costMonitor = ();
costMonitor.({
: ,
: ,
: ,
: []
});
costMonitor.({
: ,
: ,
: ,
: [, ]
});
Cost Optimization Checklist
| Category | Action | Potential Savings |
|---|
| Licensing | Deactivate inactive users | 10-30% |
| Licensing | Review license tiers | 5-15% |
| API | Implement caching | 20-50% |
| API | Use batch operations | 10-30% |
| Storage | Archive old data | 15-40% |
| Storage | Compress attachments | 10-20% |
| Compute | Right-size instances | 20-40% |
| Compute | Enable auto-scaling | 15-30% |
Output
- Usage analysis report
- License optimization recommendations
- API efficiency improvements
- Storage reduction strategies
- Resource right-sizing configuration
Resources
Next Steps
For architecture patterns, see guidewire-reference-architecture.