Without proper monitoring, a slow WCF endpoint or memory leak can degrade user experience for hours before anyone notices. Performance counters built into Windows Communication Foundation give you real time visibility into call rates, durations, and security events, but they are disabled by default. With the right setup, you can detect bottlenecks, track service health, and resolve issues before they cascade into downtime.
This guide walks through enabling WCF performance counters, setting up monitoring tools, and troubleshooting common issues step by step. Whether you use built in Performance Monitor, SaaS APM platforms, or self hosted observability tools, you will know exactly how to instrument WCF services for production visibility.
Prerequisites
Before setting up WCF performance monitoring, verify the following:
- WCF service deployed on IIS or self hosted in a Windows environment
- Administrator access to the server hosting the WCF service
- Access to modify the
app.configorweb.configfile for your WCF application - Windows Performance Monitor (perfmon.exe) available on the server
- For APM tool integration: agent installation permissions and network access to the monitoring backend
- For self hosted monitoring: resources to run an observability stack like infrastructure monitoring platforms inside your VPC
Step 1: Enable WCF Performance Counters in Configuration
WCF performance counters are off by default. The fastest way to turn them on is by editing your service configuration file.
Open your web.config (for IIS hosted services) or app.config (for self hosted services) and locate the <system.serviceModel> section. Add the diagnostics element with performanceCounters set to All:
<configuration>
<system.serviceModel>
<diagnostics performanceCounters="All" />
</system.serviceModel>
</configuration>
Save the file and restart your WCF service. This enables all three performance counter categories: ServiceModelService, ServiceModelEndpoint, and ServiceModelOperation.
If you want to enable counters only at the service level to reduce overhead, use ServiceOnly instead of All. For production environments where every counter creates measurable resource cost, start with ServiceOnly and add endpoint or operation counters only where needed.
Alternative: Enable counters machine wide
If you manage multiple WCF applications on the same server and want counters enabled by default for all of them, edit the Machine.config file located in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\ (or the appropriate .NET version path).
Add the same <diagnostics performanceCounters="All" /> line under <system.serviceModel> in Machine.config. After saving, restart the server to apply the change globally.
This approach reduces per application configuration but applies counters to every WCF service on the machine, which increases baseline resource consumption.
Step 2: Verify Counters Are Active Using Performance Monitor
After enabling counters, confirm they are collecting data using Windows Performance Monitor.
Open Run (Windows + R), type perfmon.exe, and press Enter. In the Performance Monitor window, click the green plus icon to add counters.
In the counter selection dialog, expand the following performance object categories:
- ServiceModelService 4.0.0.0 (for service level metrics)
- ServiceModelEndpoint 4.0.0.0 (for endpoint level metrics)
- ServiceModelOperation 4.0.0.0 (for operation level metrics)
Select counters such as:
- Calls: Total number of calls to the service
- Calls Per Second: Call rate for the service
- Average Call Duration: Mean latency per call
- Security Calls Not Authorized: Failed authorization attempts
Add these counters and observe the live graph. If the graph remains flat at zero and your service is receiving traffic, the counters are not enabled correctly. Recheck the configuration file and ensure the service has been restarted.
For continuous monitoring, create a Data Collector Set by right clicking Data Collector Sets in Performance Monitor, selecting New, and configuring a scheduled log of your WCF counters to CSV or binary format. This allows you to review historical trends without keeping Performance Monitor open continuously.
Step 3: Set Up Alerts for Critical Thresholds
Real time alerts prevent incidents from escalating. Performance Monitor supports threshold based alerts for WCF counters.
Right click Alerts under Data Collector Sets, select New, and choose Alert. Name the alert (for example, WCF High Call Duration), then add a performance counter like Average Call Duration under ServiceModelOperation 4.0.0.0.
Set the alert threshold. For example, trigger an alert when Average Call Duration exceeds 3000 milliseconds. Configure the action: log an event, run a script, or send a notification.
For critical services, set alerts on:
- Calls Per Second dropping to zero (indicates service unavailability)
- Security Calls Not Authorized spiking (potential attack or misconfiguration)
- Average Call Duration exceeding your SLA threshold
Performance Monitor alerts are local to the server. For distributed WCF deployments or centralized alerting, integrate with an APM tool or observability platform.
Step 4: Integrate WCF with an APM Tool for Deeper Visibility
Performance counters show service level metrics but lack trace context, dependency mapping, or distributed request flow. APM tools fill this gap by correlating WCF calls with backend database queries, external API calls, and downstream services.
Most APM tools support WCF through:
- Agent based instrumentation: Install an agent (for example, Datadog .NET APM agent, New Relic .NET agent, or CubeAPM OpenTelemetry agent) on the server hosting your WCF service
- OpenTelemetry compatible WCF instrumentation: Use the OpenTelemetry .NET SDK to instrument WCF endpoints and export telemetry to any OTel compatible backend
Example: Instrumenting WCF with OpenTelemetry
Install the OpenTelemetry .NET SDK and WCF instrumentation package via NuGet:
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Instrumentation.Wcf
Add OpenTelemetry to your application startup (in Program.cs or Global.asax.cs):
using OpenTelemetry;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
var serviceName = "YourWcfService";
var resourceBuilder = ResourceBuilder.CreateDefault().AddService(serviceName);
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetResourceBuilder(resourceBuilder)
.AddWcfInstrumentation()
.AddOtlpExporter(options =>
{
options.Endpoint = new Uri("https://your-otel-endpoint:4317");
})
.Build();
This exports WCF trace data to any OpenTelemetry Protocol (OTLP) compatible backend. CubeAPM supports native OTLP ingestion and correlates WCF traces with logs and infrastructure metrics automatically.
For teams already using Datadog or New Relic agents, WCF instrumentation is often enabled by default once the agent is installed. Verify in the APM dashboard that WCF service endpoints appear as monitored transactions.
Step 5: Monitor Database Queries and External Dependencies
Slow database queries or external API calls are common WCF performance bottlenecks. APM tools with dependency tracing show exactly which queries or external services contribute to high endpoint latency.
Enable SQL query tracking in your APM agent configuration. For example, in the Datadog .NET agent, set DD_TRACE_AGENT_URL and ensure SQL tracing is enabled. In CubeAPM, database queries are captured by default when OpenTelemetry instrumentation is active.
Review the APM trace view for each slow WCF request. Identify:
- Database queries exceeding 500 ms
- External HTTP calls with high latency or error rates
- Serialization or deserialization delays in WCF message processing
Optimize queries by adding indexes, caching frequently accessed data, or reducing payload size. For external dependencies, implement circuit breakers or timeouts to prevent cascading failures.
Step 6: Adjust Concurrency and Throttling Settings
WCF throttling limits the number of concurrent calls, sessions, and instances to prevent resource exhaustion. Default throttling values are conservative and often too low for production workloads.
Edit your web.config or app.config to increase throttling limits under <system.serviceModel>:
<serviceBehaviors>
<behavior name="throttlingBehavior">
<serviceThrottle maxConcurrentCalls="100"
maxConcurrentSessions="100"
maxConcurrentInstances="100" />
</behavior>
</serviceBehaviors>
Apply the behavior to your service:
<service name="YourNamespace.YourService" behaviorConfiguration="throttlingBehavior">
<!-- endpoint configuration -->
</service>
Monitor Calls Per Second and Average Call Duration after increasing throttling. If duration decreases and throughput increases, the previous limits were a bottleneck. If duration increases, the bottleneck is downstream (database, external API, or CPU).
For services running on IIS, also check the application pool settings. Increase the queue length and worker process count if throttling improvements do not reduce latency.
Troubleshooting Common Issues
Performance counters show zero despite service activity
Verify the diagnostics element is present in the correct configuration file. If you edited app.config but the service runs in IIS, the active configuration is web.config. Restart the application pool or service after making changes.
Check that the .NET version in the counter category matches your runtime. For .NET Framework 4.x, the category is ServiceModelService 4.0.0.0. For earlier versions, the category name differs.
WCF service becomes unresponsive under load
High concurrency often exhausts the default throttling limits. Increase maxConcurrentCalls, maxConcurrentSessions, and maxConcurrentInstances as shown in Step 6.
Check for database connection pool exhaustion. WCF services under load may exhaust available database connections if queries are slow or long running. Increase the connection pool size or optimize slow queries.
Review memory usage in Performance Monitor. Add .NET CLR Memory counters for your WCF process. If Gen 2 collections are frequent or memory grows unbounded, investigate object disposal and large object allocations.
APM tool does not show WCF traces
Ensure the APM agent or OpenTelemetry instrumentation is installed and configured correctly. For OpenTelemetry, verify the exporter endpoint is reachable and the WCF instrumentation package is added.
If using IIS, confirm the agent is loaded in the application pool. For self hosted services, verify the agent initialization code runs before the service starts.
Check the APM backend for ingestion errors or sampling configuration that may be dropping WCF traces.
High latency in WCF endpoints
Use the APM trace view to identify slow database queries, external API calls, or serialization delays. If no single dependency is slow, the bottleneck may be CPU or thread pool starvation.
Add counters for .NET CLR LocksAndThreads to monitor thread pool usage. If the thread pool queue length is consistently high, increase the minimum thread pool size or reduce blocking operations in WCF service methods.
For serialization heavy services, profile message size and consider using binary encoding instead of text based SOAP if the client supports it.
Monitoring WCF with CubeAPM
CubeAPM provides full stack observability for WCF services with OpenTelemetry native instrumentation, unlimited retention, and self hosted deployment. It runs inside your VPC or on premises, keeping WCF telemetry data local and compliant with data residency requirements.
CubeAPM correlates WCF traces with database queries, infrastructure metrics, and logs in a single view. It automatically indexes high cardinality fields like operation name, endpoint address, and error type, making it fast to filter slow requests or failed calls.
For teams monitoring WCF alongside other PHP application monitoring tools, Ruby Application Monitoring tools, or Linux Application Monitoring tools, CubeAPM unifies telemetry from all services in one platform.
Pricing is predictable at $0.15/GB ingested with no per seat fees or hidden charges. All WCF telemetry is retained indefinitely at the same rate with no cold storage tier or query limits.
Setup requires installing the OpenTelemetry .NET SDK in your WCF service and configuring the OTLP exporter to point to your CubeAPM instance. Traces, metrics, and logs flow automatically with no proprietary agents or vendor lock in.
For WCF services processing sensitive data, CubeAPM’s self hosted deployment ensures no telemetry leaves your infrastructure, avoiding egress costs and external SaaS dependencies.
Disclaimer: The information in this article reflects the latest details available at the time of publication and may change as technologies and products evolve. Features, pricing, and plan limits can change over time. Always verify the latest information directly with the vendor before making purchasing or deployment decisions.
Frequently Asked Questions
How do I enable WCF performance counters for a single service without affecting others?
Add the diagnostics element with `performanceCounters=”All”` to the specific service’s `web.config` or `app.config` file. This enables counters only for that service without modifying machine wide settings.
What is the difference between ServiceModelService, ServiceModelEndpoint, and ServiceModelOperation counters?
ServiceModelService counters aggregate metrics for the entire WCF service. ServiceModelEndpoint counters track performance per endpoint. ServiceModelOperation counters measure individual operations on each endpoint, giving the most granular view.
Can I use WCF performance counters with self hosted services?
Yes. Self hosted WCF services support performance counters if the diagnostics element is added to the `app.config` file. Ensure the hosting process has sufficient permissions to write performance counter data.
How do I reduce performance counter overhead in production?
Use `performanceCounters=”ServiceOnly”` to enable only service level counters. Avoid enabling operation level counters unless you need per operation visibility. Monitor CPU and memory usage to confirm the overhead is acceptable.
What APM tools support WCF instrumentation?
Datadog, New Relic, Dynatrace, and CubeAPM all support WCF monitoring through .NET agents or OpenTelemetry instrumentation. OpenTelemetry offers the most flexibility and avoids vendor lock in.
How do I monitor WCF services running in Docker containers?
Install the OpenTelemetry .NET SDK in the container and export telemetry to an OTLP endpoint accessible from the container network. For JavaScript Application Monitoring tools or other containerized services, the same OpenTelemetry setup applies.
What is the recommended retention period for WCF performance counter logs?
Retain at least 30 days of counter data to identify trends and recurring issues. For compliance or post mortem analysis, consider 90 days or longer. Self hosted APM tools like CubeAPM offer unlimited retention with no extra cost.





