问题
I have developed a server application which can send push messages to apple servers. I've tested it with couple of devices and i'm able to get the messages on the device. The problem is , i have no way to know how my application will perform when i have around a million devices in my database. Is there a way to load test your server application in this scenario.
回答1:
Couldn't you use test data? You could fill your database with a test script. Like random device-IDs..? The Apple APS of course won't accept the messages, but you could test your capacities, couldnt you?
回答2:
I see what you want and rather, i did face the same problem, what worked for me was the reverse engineering. I just looked into the library and checked for the function which validates the deviceToken. So while creation of dummy device token i just made sure that the generated token is valid as per the library.
The following code will let you generate valid device Tokens, now its on you to how many millions of tokens to generate using this function.
def generateRandomDeviceTokenAndAppendItToJson(tokenLength: Int) {
val randomlyGeneratedDeviceToken = new StringBuilder()
randomlyGeneratedDeviceToken.append(" \"")
(1 to tokenLength) foreach {
times: Int =>
if (tokenLength equals Device.Apple)
randomlyGeneratedDeviceToken.append(validCharacter().toString.charAt(0))
else
randomlyGeneratedDeviceToken.append(Random.alphanumeric.head)
}
randomlyGeneratedDeviceToken.append("\",")
println(randomlyGeneratedDeviceToken)
writer.write(randomlyGeneratedDeviceToken.toString())
}
private def validCharacter(): Int = {
val a = Random.alphanumeric.head
if ('0' <= a && a <= '9')
return (a - '0')
else if ('a' <= a && a <= 'f')
return ((a - 'a') + 10)
else if ('A' <= a && a <= 'F')
return ((a - 'A') + 10)
validCharacter()
}
The apple deviceToken is of 64 character so you will need to iterate on it for 64 times.
来源:https://stackoverflow.com/questions/9636526/load-testing-apple-push-notification-server-application