Stay organized with collections
Save and categorize content based on your preferences.
publicinterfaceBackendService
BackendService allows you to retrieve information about
backend servers. Backend servers are long running addressable
servers that can be used for applications that need to keep
persistent state in ram between requests.
This API allows you to retrieve information about the backend
handling the current request. It also allows you to to get the
address of a specific backend instance in such a way that a local
server is used during development and a production server is used
in production.
Get the address of a specific backend instance in such a way that a local
instance is used during development and a production server instance is
used in production.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003e\u003ccode\u003eBackendService\u003c/code\u003e is an interface for retrieving information about backend servers, which are long-running servers designed to maintain persistent state between requests.\u003c/p\u003e\n"],["\u003cp\u003eThis API is now deprecated and should be replaced with \u003ccode\u003ecom.google.appengine.api.modules.ModulesService\u003c/code\u003e, as outlined in the modules documentation.\u003c/p\u003e\n"],["\u003cp\u003eIt provides the ability to retrieve the address of a specific backend or backend instance, with automatic adjustments for local development versus production environments.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBackendService\u003c/code\u003e has static fields such as \u003ccode\u003eBACKEND_ID_ENV_ATTRIBUTE\u003c/code\u003e and \u003ccode\u003eINSTANCE_ID_ENV_ATTRIBUTE\u003c/code\u003e which are environment attribute keys for storing the backend name and instance ID, respectively.\u003c/p\u003e\n"],["\u003cp\u003eThe interface allows you to retrieve the name and id of the backend instance handling the current request, if the request is handled by a backend.\u003c/p\u003e\n"]]],[],null,["# Interface BackendService (2.0.0)\n\n public interface BackendService\n\n[BackendService](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.backends.BackendService) allows you to retrieve information about\nbackend servers. Backend servers are long running addressable\nservers that can be used for applications that need to keep\npersistent state in ram between requests.\n\n\nThis API is deprecated and has been replaced by\n[com.google.appengine.api.modules.ModulesService](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.modules.ModulesService). Please update your code as soon as\npossible. See the modules documentation for more information:\n\u003chttps://developers.google.com/appengine/docs/java/modules/converting\u003e\n\n\nThis API allows you to retrieve information about the backend\nhandling the current request. It also allows you to to get the\naddress of a specific backend instance in such a way that a local\nserver is used during development and a production server is used\nin production.\n\nStatic Fields\n-------------\n\n### BACKEND_ID_ENV_ATTRIBUTE\n\n public static final String BACKEND_ID_ENV_ATTRIBUTE\n\nEnvironment attribute key where the backend name is stored.\nSee Also: [BackendService#getCurrentBackend()](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.backends.BackendService#com_google_appengine_api_backends_BackendService_getCurrentBackend__)\n\n### DEVAPPSERVER_PORTMAPPING_KEY\n\n public static final String DEVAPPSERVER_PORTMAPPING_KEY\n\n### INSTANCE_ID_ENV_ATTRIBUTE\n\n public static final String INSTANCE_ID_ENV_ATTRIBUTE\n\nEnvironment attribute key where the instance id is stored.\nSee Also: [BackendService#getCurrentInstance()](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.backends.BackendService#com_google_appengine_api_backends_BackendService_getCurrentInstance__)\n\n### REQUEST_HEADER_BACKEND_REDIRECT\n\n public static final String REQUEST_HEADER_BACKEND_REDIRECT\n\n### REQUEST_HEADER_INSTANCE_REDIRECT\n\n public static final String REQUEST_HEADER_INSTANCE_REDIRECT\n\nMethods\n-------\n\n### getBackendAddress(String backend)\n\n public abstract String getBackendAddress(String backend)\n\nGet the address of a specific backend in such a way that a local server is\nused during development and a production server is used in production.\n\n### getBackendAddress(String backend, int instance)\n\n public abstract String getBackendAddress(String backend, int instance)\n\nGet the address of a specific backend instance in such a way that a local\ninstance is used during development and a production server instance is\nused in production.\n\n### getCurrentBackend()\n\n public abstract String getCurrentBackend()\n\nGet the name of the backend handling the current request.\n\n### getCurrentInstance()\n\n public abstract int getCurrentInstance()\n\nGet the instance handling the current request."]]